Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get HTML with VBA ?

Status
Not open for further replies.

stevedemo

Programmer
Mar 30, 2008
54
US
Is it possible to grab a web page html with VBA ?
If so how ?

Thanks !!

Steve

All I want is the chance to prove money won't make me happy.
 


I was able to convert some VB. However the only page I can get it to load is google nothing else will load.

Suggestions ?

Code:
Private Sub Command1_Click()
  Dim doc As Object
 
  WebBrowser7.Navigate url:=Text1.Value

  Do
  DoEvents
  Loop Until Not WebBrowser7.Busy
  Set doc = WebBrowser7.Document
  Text3.Value = doc.All(0).innerHTML
End Sub



All I want is the chance to prove money won't make me happy.
 
Have you checked the value of Text1.Value?

 
Hello Remou,

Yes I have, I have even hard coded a different URL. I suspect for the most part the code is working but I am returning a NULL value here: doc.All(0).innerHTML that part has me puzzled.

The "webbrowser" was never my strong point in any language. I was hoping there was a different call I could make to grab the HTML.


Steve

All I want is the chance to prove money won't make me happy.
 

Got it !!!!


Code:
  ' Go to Page
  WebBrowser7.Navigate url:=Text1.Value

  ' Get HTML
  Do
  DoEvents
  Loop Until Not WebBrowser7.Busy
  
  Text3.Value = WebBrowser7.Document.All(1).innerHTML

All I want is the chance to prove money won't make me happy.
 
Hello Steve,

I tried to use the code you posted in your last post and it did not work...

I tried:
' Go to Page
WebBrowser7.navigate url:="
' Get HTML
Do
DoEvents
Loop Until Not WebBrowser7.Busy

txtSource = WebBrowser7.Document.all(1).innerHTML

It does not grab the whole source code and even what it grabs is incomplete... Am I missing something?

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top