我正在尝试解析基于Web的数据透视表。 不幸的是,为了访问我需要的所有数据,我需要在基于Web的数据透视表中扩展其他行。我认为,当我单击+号以展开其他行时,脚本将从数据库中下载其他数据。
无论如何,这是+号的html代码:
<DIV class="clip9x9 di-img" onclick=_Ewa.Gim.tpdfce(event);>
<INPUT title=Expand class=ewaboot_expand type=image alt=Expand src="http://...">
</DIV>
我设法使用IE.document.getElementsByTagName("Div")
和If循环将正确的元素放入变量中(由于某种原因GetElementByClassName
会使我的IE崩溃),但是.Click
或{ {1}}方法有效。我还在.FireEvent (OnClick)
下面的Input元素上尝试了这两种方法,但它们都不起作用。
这是代码
DIV
当我在“间谍窗口”(VBA编辑器)中查看我的Obj元素的onclick属性时,onclick属性旁留有一个+号,并且在其中进行检查时,没有任何变量归属于该属性。我觉得这很奇怪,因为HTML代码指示一个Sub Test()
Dim IE As InternetExplorer
Dim div As Variant
Dim Obj As Variant
Dim WebUrl As String
WebUrl = "http://..../filename.aspx"
Set IE = New InternetExplorerMedium
Sleep 1000
IE.Visible = True
IE.navigate WebUrl
Do While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
Sleep 1000
Loop
Set div = IE.document.getElementsByTagName("Div")
For Each Obj In div
If Obj.className = "clip9x9 di-img" Then
Obj.Click
Obj.FireEvent ("OnClick")
End If
Next i
End Sub
,我相信它是指用于扩展数据透视表行的脚本。
任何帮助将不胜感激