<p>First, make sure that you can type &quot;print somefile.txt&quot; 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, &quot;Alan Jump&quot; &lt;<a href="mailto:alan.jump@gmail.com">alan.jump@gmail.com</a>&gt; 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&#39;m having is getting printing functionality to work.<br>
The code snippet in question:<br>
<br>
        if platform.system() == &#39;Windows&#39;:<br>
            try:<br>
                import win32api<br>
            except:<br>
                print(&#39;* FAILED TO LOAD WINDOWS EXTENSION&#39;)<br>
                return<br>
            try:<br>
                win32api.ShellExecute (0, &quot;print&quot;, filename, None, &quot;.&quot;, 0)<br>
            except:<br>
                print(&#39;* FAILED TO SEND PRINT TO WINDOWS PRINTER&#39;)<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&#39;s throwing an exception when trying to write to<br>
the print device. I commented out the &quot;try - except&quot; statements, and got<br>
an error message that the device could not be opened. I&#39;m wondering if<br>
there&#39;s a UAC or permissions issue I&#39;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>