2012-11-03 72 views
0

想使用MSHTML填補通過WebBrowser控件vb.net形式,無法投型「系統.__ ComObject」到接口類型「mshtml.HTMLElementCollection的COM對象

Dim doc As MSH.IHTMLDocument2 = DirectCast(wbMain.Document.DomDocument, MSH.IHTMLDocument2) 
Dim buttons As MSH.HTMLElementCollection = doc.getElementsByTagName("button") 
Dim Inputs As MSH.HTMLElementCollection = doc.getElementsByTagName("input") 

,但我得到出現以下錯誤

Unable to cast COM object of type 'System.__ComObject' to interface type 'mshtml.HTMLElementCollection'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{3050F56B-98B5-11CF-BB82-00AA00BDCE0B}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

任何人都可以幫我解決可能的解決方案嗎?

回答

1

Dim buttons As MSH.HTMLElementCollection

錯誤的類型。這應該是一個IHTMLElementCollection。請注意前導I. MSDN頁面is here

缺少I的類型是coclass,而不是接口。當他們想要創建自己的集合對象時由腳本客戶端使用。

+0

謝謝,我感謝你的幫助 – Smith

相關問題