Mulitple HTMLdocuments

Tgaboreau90

New Member
Joined
May 25, 2012
Messages
26
Hello,

If i want to pull data from a website i do this....

Code:
Dim ie As New InternetExplorer

  ie.Navigate "www.example.com"

  Dim doc As HTMLDocument

Set doc = ie.document

Dim sSS As String

sSS = doc.getElementsByTagName("Table")(0).innerText

ActiveCell.Offset(0, 1) = sSS
but what do i do if i then want to navigate to a second website and pull data from there?

because whatever i do my code only pulls data from the first website.

i've tried...

Code:
  Dim doctwo As HTMLDocument

Set doctwo = ie.document
and various other things, but can't get it to work.

i'm a beginner at vba as you can probably tell.

please help.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Maybe like this:
Code:
Dim ie As New InternetExplorer

  ie.Navigate "www.example.com"

  Dim doc As HTMLDocument

Set doc = ie.document

Dim sSS As String

sSS = doc.getElementsByTagName("Table")(0).innerText

ActiveCell.Offset(0, 1) = sSS

  ie.Navigate "www.example.com"

Set doc = ie.document

sSS = doc.getElementsByTagName("Table")(0).innerText

ActiveCell.Offset(0, 2) = sSS
 
Upvote 0
just realised what it was.

wasn't using do events so it was redefining the document before the url had even changed. silly me.

cheers for your help.
 
Upvote 0

Forum statistics

Threads
1,202,962
Messages
6,052,815
Members
444,602
Latest member
Cookaa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top