Automating IE 6.0

Mike Driscoll kyosohma at gmail.com
Mon Apr 28 20:56:15 EDT 2008


Michael Harris wrote:
>
> 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.constants
> .OLECMDEXECOPT_DONTPROMPTUSER)
>  
>
> Why am I getting this error?
>
I don't know why this is happening, so I recommend posting it to the 
pywin32 group: http://mail.python.org/mailman/listinfo/python-win32

You might also check out the PAMIE project: 
http://sourceforge.net/projects/pamie

SendKeys would also work, but it's kind of messy.

Mike



More information about the Python-list mailing list