Automating IE 6.0
Michael Harris
michael.harris at MCC-CORP.COM
Mon Apr 28 13:42:00 EDT 2008
I tried to use the sample code to print a webpage via ie and I get the
following error:
Traceback (most recent call last):
File
"C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py"
, line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\ie.py", line 14, in <module>
ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,
win32com.client.constants.OLECMDEXECOPT_DONTPROMPTUSER)
NameError: name 'win32com' is not defined
I have the win32com module installed and I clicked on makepy.py and
selected Microsoft Internet Controls (1.1). The code was:
from win32com.client import Dispatch
from time import sleep
ie = Dispatch("InternetExplorer.Application")
ie.Visible = 1
ie.Navigate("http://www.cnn.com" <http://www.cnn.com%22> )
if ie.Busy:
sleep(2)
# print the current IE document without prompting the user for the
printerdialog
ie.ExecWB(win32com.client.constants.OLECMDID_PRINT,win32com.client.const
ants
.OLECMDEXECOPT_DONTPROMPTUSER)
Why am I getting this error?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080428/e70469c2/attachment.html>
More information about the Python-list
mailing list