[python-win32] A little help for a n00b, please

Alan Jump alan.jump at gmail.com
Sun May 6 03:24:54 CEST 2012


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


More information about the python-win32 mailing list