我最近学习通过VBA excel在IE上打开网站。现在我正在尝试添加代码,将检查是否有活动的IE是否打开,如果是,它将打开一个新的选项卡来浏览网站并再次执行相同的操作。不幸的是,我没有任何运气。希望有人可以帮助我。先谢谢
这是我的代码: >
Sub OpenIE()
Dim IE As Object
Dim site As String
Set IE = CreateObject("InternetExplorer.Application")
site = "https://www.automateexcel.com/excel/"
IE.Visible = True
IE.navigate site
Application.StatusBar = site & " " & "is loading"
Do While IE.readyState = 4: DoEvents: Loop
Do Until IE.readyState = 4: DoEvents: Loop
Application.StatusBar = site & " " & "is loaded"
Set IE = Nothing
End Sub
答案 0 :(得分:0)
这是如何以编程方式在IE对象中打开多个选项卡
Sub Test()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Navigate "https://amazon.com" '1st tab
.Navigate "https://flipkart.com", CLng(2048) '2nd
.Navigate "https://snapdeal.com", CLng(2048) '3rd
.Visible = True
End With
End Sub
答案 1 :(得分:0)
这也有效
Sub Test()
Dim IE As Object
Set IE = Nothing
Set IE = CreateObject("InternetExplorer.Application")
Set cell = Cells(1, 1)
For i = 1 To 5
IE.navigate "https://www.google.com/search?q=" & Cells(i, 1) & "&rlz=1C1CHBF_enUS828US828&oq=62654962004&aqs=chrome..69i57j69i59.95j0j4&sourceid=chrome&ie=UTF-8", CLng(2048)
IE.Visible = True
Next
End Sub