[python-win32] Python Automation Question

Mike Driscoll mdriscoll at co.marshall.ia.us
Mon Feb 22 17:37:04 CET 2010


Hi Greg,

On 1:59 PM, Roberts, Gregory (Contractor) wrote:
> We have decided to oset the default printer in a macro which we must run
> on the excel report and hope that all will work on Monday when in
> production.
>
> I would like to find a python solution which I could refactor into the
> correct place.  Again, my wits with Python still have not formed.
> Also... I am unable to dedicate to much time to this task for the time
> being.
>
> Thanks for the suggestions.  I will try and think outside the box using
> them as guidance.
>
> Greg
>
>
>    

I'm not sure why the other PyWin32 guys didn't mention this, but you can 
do either of the following:

import  win32print
win32print.SetDefaultPrinter('My Printer Name')

import  subprocess
subprocess.call(r'rundll32 printui.dll PrintUIEntry /y /n\\UNC\path\to\printer')


I have a couple of other tips here: 
http://www.blog.pythonlibrary.org/2010/02/14/python-windows-and-printers/  
and Tim Golden's site has at least one other script based on printers:
http://timgolden.me.uk/python/wmi/cookbook.html#show-print-jobs 
(although it has nothing to do with what you're doing).

The other guys had good suggestions too though.


-- 
*Mike Driscoll*

Blog: http://blog.pythonlibrary.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20100222/6858138a/attachment.html>


More information about the python-win32 mailing list