本文介绍了如何使用VBA Internet Explorer浏览网站上的多个链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用vba Internet Explorer在多个页面上选择选项,并且我能够使用vba打开多个标签和多个链接,但只能在第一页上导航.请检查下面给出的编码以供参考:-

I want to select options on multiple pages using vba internet explorer and i am able to open multiple tabs and multiple links using vba but only able to navigate on first page. Please check the coding given below for your reference:-

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

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

Please provide any solution to navigate on second page as well.

推荐答案

在其他语句中更正语法:

Correct your syntax within the Else Statement:

Else
    IE.Navigate url, 2048

代替

Else
    IE.Navigate2 url, 2048

这篇关于如何使用VBA Internet Explorer浏览网站上的多个链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 10:55