I had the same MX340 problem. My printer was working fine over WiFi connection to my Airport Extreme for years and then suddenly, about a month ago, it stopped printing after the first print job. I can print once and then I have to power-cycle the printer to get it to print another time and then I have to repeat the power-cycle.
The printer seems to be "forgotten" by the network or lose its connection after the first print job.
On my MacBookPro 10.6.8 I get the error code 300...yadayadayad... On my iMac 10.5.8 it just says :communications error".
HERE IS THE FIX - I got it off this link - http://www.techsurvivors.net/forums/index.php?showtopic=24681
You have to connect to the MX340 using the printer cable that came with the printer (or any USB printer cable) and set up a hardwired USB printer queue. Then print a couple of print jobs - I use TextEdit and type in "1234". Then try the same thing but select your WiFi print queue - I just type another line on the same sheet of paper with TextEdit.
The WiFi connection should work again. I did this a few more times and then disconnected the USB cable and now it continues to work without the USB print queue being used. I can also print to the WiFi queue with my iMac.
If you still have problems I suggest you set up the printer again on the WiFi router using the "print cable connection" method. Here's a link to a webpage someone kindly provided instructions for the process:
http://machinesaredigging.com/2011/04/08/how-to-install-the-printer-canon-mx340- wi-fi-without-the-cd-on-mac/
Good luck!