[python-win32] A little help for a n00b, please
Vernon Cole
vernondcole at gmail.com
Sun May 6 05:44:22 CEST 2012
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.
On May 5, 2012 7:25 PM, "Alan Jump" <alan.jump at gmail.com> wrote:
> Trying to massage an older package (not written by me) into functioning
> order. The issue I'm having is getting printing functionality to work.
> The code snippet in question:
>
> if platform.system() == 'Windows':
> try:
> import win32api
> except:
> print('* FAILED TO LOAD WINDOWS EXTENSION')
> return
> try:
> win32api.ShellExecute (0, "print", filename, None, ".", 0)
> except:
> print('* FAILED TO SEND PRINT TO WINDOWS PRINTER')
> return
>
> The output file is generated in a separate code section and the filename
> being passed has been verified, but I invariably get the message in the
> second exception. That tells me the win32api is being properly imported,
> but for some reason, it's throwing an exception when trying to write to
> the print device. I commented out the "try - except" statements, and got
> an error message that the device could not be opened. I'm wondering if
> there's a UAC or permissions issue I'm running up against.
>
> Specifics: Windows Vista Home Basic, fully patched. Python 3.2,
> PyWindows build 217.
>
> 73 de N5ILN/6
> Alan
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120505/73de12bc/attachment.html>
More information about the python-win32
mailing list