[Tutor] COM & IE problems

Aaron Colichia coreconcern at gmail.com
Thu Jun 26 19:05:12 CEST 2008


I've been using win32com.client to work with IE via COM, but recently had a
need to start using comtypes.client because it provides a better wrapper for
IE.
However, when I want to grab an existing IE using
comtypes.client.GetActiveObject() the result is always the same as
illustrated below

H:\devel\workspace\web\src>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]
on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import comtypes.client
>>> ie = comtypes.client.CreateObject('InternetExplorer.Application')
>>> ie.visible = True
>>> ie.__clsid
'{0002DF01-0000-0000-C000-000000000046}'
>>> ie._iid_
GUID("{D30C1661-CDAF-11D0-8A3E-00C04FC9E26E}")
>>> newie = comtypes.client.GetActiveObject('InternetExplorer.Application')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python25\lib\site-packages\comtypes\client\__init__.py", line
164, in
 GetActiveObject
    obj = comtypes.GetActiveObject(clsid, interface=interface)
  File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 990, in
GetAct
iveObject
    oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
  File "\loewis\25\python\Modules\_ctypes\callproc.c", line 757, in
GetResult
WindowsError: [Error -2147221021] Operation unavailable
>>> newie = comtypes.client.GetActiveObject(ie.__clsid)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\python25\lib\site-packages\comtypes\client\__init__.py", line
164, in
 GetActiveObject
    obj = comtypes.GetActiveObject(clsid, interface=interface)
  File "C:\Python25\Lib\site-packages\comtypes\__init__.py", line 990, in
GetAct
iveObject
    oledll.oleaut32.GetActiveObject(byref(clsid), None, byref(p))
  File "\loewis\25\python\Modules\_ctypes\callproc.c", line 757, in
GetResult
WindowsError: [Error -2147221021] Operation unavailable
>>>

Has anyone got any bright ideas on how to get this working properly?  I
really appreciate any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080626/4ab43719/attachment.htm>


More information about the Tutor mailing list