提前感谢您提供的任何帮助。我正在尝试激活与Excel VBA的链接,以更改仪表板显示的数据的视图。我已经成功地执行了登录和导航过程,并且相信在这一步之后,scraping元素将顺利运行。我不相信我的目标是正确的元素或没有正确地构造VBA序列。
我试图在下面的HTML中触发“顾问视图”:
<div style="width:100%; clear:both">
<ul class="tab_menu clearfix" style="padding-top:5px;">
<li id="site_ti" class="table_tab_item">
<a href="#" onclick="update_table_tab('site'); return false;">By Site</a>
</li>
<li id="director_ti" class="table_tab_item">
<a href="#" onclick="update_table_tab('director'); return false;">By Director</a>
</li>
<li id="team_lead_ti" class="table_tab_item">
<a href="#" onclick="update_table_tab('team_lead'); return false;">By Team Manager</a>
</li>
<li id="consultant_ti" class="table_tab_item">
<a href="#" onclick="update_table_tab('consultant'); return false;">By Consultant</a>
</li>
</ul>
我使用了以下程序,但没有结果:
以下是公开声明的开头部分:
Public Sub Huddle_Report_Scrape(ObjIE)
Dim ie As SHDocVw.InternetExplorer
Dim doc As MSHTML.HTMLDocument 'If you have a reference to the HTML Object Library
Dim objShell, obj, objInputs, objButtons As Object
Dim htmldoc As MSHTML.IHTMLDocument 'Document object
Dim tbl As MSHTML.IHTMLElementCollection
Dim eleColtr As MSHTML.IHTMLElementCollection 'Element collection for tr tags
Dim eleColtd As MSHTML.IHTMLElementCollection 'Element collection for td tags
Dim eleRow As MSHTML.IHTMLElement 'Row elements
Dim eleCol As MSHTML.IHTMLElement 'Column elements
Dim Table As MSHTML.HTMLTable
Dim row As MSHTML.HTMLTableRow
Dim cell As MSHTML.HTMLTableCell
Dim col As MSHTML.HTMLTableCol
下面是我调用的触发顾问视图的函数。
Function FnConsultantView(ObjPage)
With ObjPage
Set li = .getElementByValue("consultant")
With li
.Focus
.FireEvent "onclick"
End With
End With
MsgBox ("Operation Completed")
我也尝试过使用以下帖子中的元素,但运气不佳:FireEvent and IE11
最佳答案
它在一次火灾中起作用。
Function FnConsultantView(ObjPage)
With ObjPage .getElementById ("consultant_ti") .getElementsByTagName("a")(0).FireEvent ("onclick")
End With MsgBox ("Operation Completed")
关于html - Excel Web Scraping-ul列表项上的fireEvent,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39005111/