Reputation: 371
Please kindly assist regarding below issues.
Background:
I enter 25 stock codes in column B. I would like to open them all in internet explorer automatically.
Issue:
After I run the below code, it only open 1 internet explorer window. And the url is "http://finance.yahoo.com/q?s="
How am i able to open multiple internet explorer windows/tabs and navigate to the stock codes which i want. Instead of just 1 internet explorer windows pop out?
My computer info:
1.window 8.1
2.excel 2013
3.ie 11
My excel reference:
Microsoft Object Library: yes
Microsoft Internet Controls: yes
Microsoft Form 2.0 Object library: yes
Microsoft Script Control 1.0: yes
URL:
http://finance.yahoo.com/q?s=ibm
Below is my VBA code:
Private Sub CommandButton1_Click()
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
For r = 2 To 50
With ie
.Visible = 1
.navigate "http://finance.yahoo.com/q?s=" & Cells(r, "B").Value
End With
Next r
End Sub
Cheers!
Upvotes: 0
Views: 5546
Reputation:
After the navigate
command you need to allow the ie
object time to get the web page.
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
For r = 2 To 50
With ie
.Visible = 1
.navigate "http://finance.yahoo.com/q?s=" & Cells(r, "B").Value
Do While (.Busy Or .ReadyState <> 4): DoEvents: Loop 'READYSTATE_COMPLETE = 4
' do something with the page here
End With
Next r
ie.quit: set ie = nothing
Upvotes: 1
Reputation: 3290
Have you tried creating multiple IE Objects?
Private Sub CommandButton1_Click()
Dim ie As Object
For r = 2 To 50
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = 1
.navigate "http://finance.yahoo.com/q?s=" & Cells(r, "B").Value
End With
Next r
End Sub
Upvotes: 0