我在 VBA 中有一個(gè)宏,它使用 Excel 自動導(dǎo)航到網(wǎng)頁。我可以通過它們的 ID 選擇元素,然后單擊或插入值來自動化站點(diǎn)。然而,當(dāng)我試圖“點(diǎn)擊”一個(gè)似乎沒有任何 ID 的鏈接/按鈕時(shí),我被卡住了。這是一個(gè) JavaScript 鏈接:<div><table class="table" id="ctl00_cphMaster_Results" style="width: 100%; border-collapse: collapse;" cellspacing="0"> <tbody><tr> <th style="width: 70px; white-space: nowrap;" scope="col"><a href="javascript:__doPostBack('ctl00$cphMaster$Results','Sort$Indicator')">True?</a></th><th class="hidden" style="width: 100px;" scope="col"><a href="javascript:__doPostBack('ctl00$cphMaster$Results','Sort$Reference')">Reference</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$cphMaster$Results','Sort$Results')">Result Number</a></th><th class="hidden" scope="col"> </th><th scope="col"><a href="javascript:__doPostBack('ctl00$cphMaster$Results','Sort$Type')">Type</a></th><th class="hidden" scope="col"></th><th class="hidden" scope="col"> </th><th class="hidden" scope="col"> </th> </tr><tr> <td align="center"><a href="Summary02.aspx?"><img title="Accepted" id="true" style="border: currentColor; border-image: none;" alt="Accepted" src="/Common/Graphics/tick_green.gif"></a><img id="Accepted" style="border: currentColor; border-image: none;" src="/Common/Graphics/tick_spacer.gif"><img id="Accepted" style="border: currentColor; border-image: none;" src="/Common/Graphics/tick_spacer.gif"></td><td class="hidden">MyValue</td><td><a href="javascript:__doPostBack('ctl00$cphMaster$Results','ResultNumber$0')">ResultNumber</a></td> </tr></tbody></table>我曾嘗試單擊“ResultNumber$0”或以某種方式觸發(fā)它,但到目前為止還沒有成功。如何讓 IE 自動點(diǎn)擊這個(gè) javascript 鏈接/按鈕?到目前為止我的代碼:Sub ClickJavaLink()Const URL = "https://myurl" Dim ie As ObjectSet ie = CreateObject("InternetExplorer.Application")With ie .navigate URL ieBusy ie .Visible = True結(jié)束子Sub ieBusy(ie As Object) Do While ie.Busy 或 ie.ReadyState < 4 DoEvents Loop End Sub
如何使 Excel VBA 自動在 IE 中單擊 javascript a href 鏈接
萬千封印
2021-10-14 13:17:52