Hello,
I'm using the code pasted below to print a document. The code worked great on
my XP machine. I moved it to my W7 machine and it gives the error below. The
weird thing is that it works great if printing a html doc from the web (such as
www.google.com), but it errors when printing a html doc from my desktop. The
document loads as I can see it on the screen, but it chokes when printing.
any ideas?
thanks,
Jeff
line 23, in Print
win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER)
File
"C:\Python27\lib\site-packages\win32com\gen_py\EAB22AC0-30C1-11CF-A7EB-0000C05BAE0Bx0x1x1.py",
line 1186, in ExecWB
, cmdexecopt, pvaIn, pvaOut)
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 456, in
_ApplyTypes_
self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0,
-2147221248), None)
import win32com.client
from time import sleep
class Printer():
def __init__(self):
pass
def WaitBusy(self, ie):
while ie.Busy:
sleep(0.5)
def WaitUntilReady(self, ie):
while ie.ReadyState!=4:
sleep(0.5)
def Print(self, doc_name):
ie = win32com.client.Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate(doc_name)
# wait for ie to open before printing
self.WaitBusy(ie)
ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,
win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER)
## ie.Quit()
p = Printer()
p.Print('test.htm')
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor