Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to read the content of a webpage with vba?

6 views
Skip to first unread message

Fluitekruid

unread,
Jul 19, 2001, 6:14:48 PM7/19/01
to
How can I read the content of a webpage and use it in Excel or Word? Using
VBA.

Ying

Jake Marx

unread,
Jul 19, 2001, 8:18:56 PM7/19/01
to
Hi Ying,

There are a few ways to get the text of a webpage programmatically via VBA.
Here's one method I posted recently to the excel.programming NG:

Private Function sGetURLText(sURL As String) As String
Dim ie As Object

Set ie = CreateObject("InternetExplorer.Application")
ie.Navigate sURL
Do Until ie.ReadyState = 4
DoEvents
Loop
sGetURLText = ie.Document.Body.InnerText
If InStr(1, sGetURLText, "The page cannot be displayed", _
vbTextCompare) Then sGetURLText = ""
ie.Quit
Set ie = Nothing
End Function


Here's another method posted by Mark Durrett in the excel.programming NG.
To use this, you must set a reference to the Microsoft XML 2.x Object
Library (via Tools | References in VBE):

Private Sub Command1_Click()
Dim xmlhttp As MSXML2.xmlhttp
Dim s As String
Dim i As Integer

Set xmlhttp = CreateObject("MSXML2.XMLHTTP")
xmlhttp.open "GET", "http://www.microsoft.com"
xmlhttp.send
s = xmlhttp.responseText
i = InStr(1, s, "Last Updated: ")
Debug.Print Mid(s, i + 14, InStr(i, s, "<") - i - 14)
End Sub


I haven't tried this one myself, but it looks like it should work well.

Regards,
Jake Marx

"Fluitekruid" <fluit...@zeelandnet.nl> wrote in message
news:3b575bfa$0$16...@news2.zeelandnet.nl...

Fluitekruid

unread,
Jul 21, 2001, 6:17:48 PM7/21/01
to
Hi Jake,

Thanks for your help. It works.
Where can I get more the information about the properties of the object
"internetexplorer" and other objects like worksheet? Can you advise me some
websites or books?

Greetings,

Ying

"Jake Marx" <ja...@longhead.com> schreef in bericht
news:#TCm4FLEBHA.580@tkmsftngp07...

0 new messages