<p>First, make sure that you can type "print somefile.txt" on a console command line and get it to work. Often the old DOS style print command - which is what you are trying here - will not work on new Windows printers. You may very likely have to use a much more complex method involving the Windows print spooler.</p>
<div class="gmail_quote">On May 5, 2012 7:25 PM, "Alan Jump" <<a href="mailto:alan.jump@gmail.com">alan.jump@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Trying to massage an older package (not written by me) into functioning<br>
order. The issue I'm having is getting printing functionality to work.<br>
The code snippet in question:<br>
<br>
if platform.system() == 'Windows':<br>
try:<br>
import win32api<br>
except:<br>
print('* FAILED TO LOAD WINDOWS EXTENSION')<br>
return<br>
try:<br>
win32api.ShellExecute (0, "print", filename, None, ".", 0)<br>
except:<br>
print('* FAILED TO SEND PRINT TO WINDOWS PRINTER')<br>
return<br>
<br>
The output file is generated in a separate code section and the filename<br>
being passed has been verified, but I invariably get the message in the<br>
second exception. That tells me the win32api is being properly imported,<br>
but for some reason, it's throwing an exception when trying to write to<br>
the print device. I commented out the "try - except" statements, and got<br>
an error message that the device could not be opened. I'm wondering if<br>
there's a UAC or permissions issue I'm running up against.<br>
<br>
Specifics: Windows Vista Home Basic, fully patched. Python 3.2,<br>
PyWindows build 217.<br>
<br>
73 de N5ILN/6<br>
Alan<br>
_______________________________________________<br>
python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br>
</blockquote></div>