[python-win32] Help! How to get IHTMLDocument3 dispatch object?
Tim Roberts
timr at probo.com
Thu May 27 20:25:25 CEST 2010
Xin Zhao wrote:
> Thanks for your kind reply.
>
> I tried the new iid, doesn't help. :(
>
> >>> import pythoncom
> >>> wo=pythoncom.New('InternetExplorer.Application')
> >>> wo.QueryInterface('{3050f485-98b5-11cf-bb82-00aa00bdce0b}')
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> pywintypes.com_error: (-2147467262, 'No such interface supported',
> None, None)
>
> Any further idea?
Yes. The Internet Explorer application doesn't support that interface,
because a single IE instance can have multiple documents. "wo" will be
an instance of IWebBrowser2. You need to fetch a document from that
interface, then fetch the IHTMLDocument3 interface from that. You want
the Document property, which is either:
doc = wo.Document
or
doc = wo.get_Document()
That "doc" object should be an IHTMLDocument2. If you really need the
"...3" version, that's where you do the QueryInterface.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list