哪个.dll包含HTMLElement类?

我正在使用Excel中的VBA(Office 2010)浏览Internet Explorer中的网页。 我的问题是我不能声明一个HtmlElement的实例,例如

 Dim myHtmlEl As HtmlElement 

返回错误“未定义用户定义的types”。

之前我曾经见过这个问题,当时我想声明一个InternetExplorer对象的实例。 解决scheme是通过VBA编辑器中的工具>>参考… >> Microsoft Internet控件创build参考。 我的理解是, Microsoft Internet Controls是一个具有InternetExplorer类定义的.dll

因此,要创build一个HtmlElement对象的实例,我需要引用定义该类的.dll 。 MSDNbuild议该.dll系统Windows窗体 。 我链接了,但类仍然是未定义的。

我怎么知道哪个.dll包含HtmlElement类?

迟到的解决scheme可能适合您的需求。

 Dim myHtmlElement As Variant Dim IE As Variant Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True IE.Navigate "http://www.stackoverflow.com/" ' Wait while site is loading While IE.Busy: DoEvents: Wend ' Get An Element Set myHtmlElement = IE.Document.getElementById("myInput") ' Set the value of an element If Not myHtmlElement Is Nothing Then myHtmlElement.Value = ActiveCell.Value ' Click a button Set myHtmlElement = IE.Document.getElementById("searchButton") myHtmlElement.Click ' Wait while site is loading While IE.Busy: DoEvents: Wend ' Navigate the IE object Dim i As Integer For i = 0 To IE.Document.getElementsByTagName("a").Length - 1 If IE.Document.getElementsByTagName("div").Item(i).innerText Like "ab*" Then ' Do Something End If Next 

以上代码基于链接的MSDN论坛。