【问题标题】:How to navigate through multiple links on website using vba internet explorer如何使用 vba Internet Explorer 浏览网站上的多个链接
【发布时间】:2017-11-15 18:11:50
【问题描述】:

我想使用 vba Internet Explorer 在多个页面上选择选项,我可以使用 vba 打开多个选项卡和多个链接,但只能在第一页上导航。请检查下面给出的代码供您参考:-

Sub mmtlink2()

Dim IE As New SHDocVw.InternetExplorer
Dim st As String
Dim htmldoc As MSHTML.HTMLDocument


Dim i As Long, d As Long, b As Long

'Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True

d = 2

For i = 1 To d

If i = 1 Then
    IE.navigate "https://www.makemytrip.com/air/search?tripType=O&itinerary=BOM-DXB-D-02Dec2017&paxType=A-1&cabinClass=E"

Else
    IE.Navigate2 "https://www.makemytrip.com/air/search?tripType=O&itinerary=BOM-DXB-D-03Dec2017&paxType=A-1&cabinClass=E", 2048
End If

 Do While IE.Busy = True Or IE.readyState <> 4
 Loop

    Set htmldoc = IE.document

    htmldoc.getElementById("Non stop").Click
Next i

End Sub

请提供任何解决方案以在第二页上导航。

【问题讨论】:

  • 是否抛出错误?具体是什么错误?
  • 当我检查第二页的不间断选项时,它不会抛出任何错误,而是仅导航到第一页。
  • 是 下一个没用,不需要On error resume next。

标签: vba excel internet-explorer


【解决方案1】:

更正您在 Else 语句中的语法:

Else
    IE.Navigate url, 2048

而不是

Else
    IE.Navigate2 url, 2048

【讨论】:

  • 使用在同一个选项卡中打开的第二个链接,但我需要在另一个选项卡中打开并想要导航第一页,打开第二页并在其上导航。
猜你喜欢
  • 1970-01-01
  • 2021-05-21
  • 1970-01-01
  • 2020-11-29
  • 2010-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多