Importing Web Page Source Code

T

tx12345

Hi

I know you can open a web page into Excel by simply entering a web
address. But is there a way to tell Excel to import the source code
instead?

Thx
 
T

Tim Williams

You can use an xmlhttp object instead if what you want is the source

Sub Tester()
MsgBox GetSource("http://www.google.com")
End Sub


Function GetSource(sURL As String) As String

Dim oXHTTP As Object

Set oXHTTP = CreateObject("MSXML2.XMLHTTP")
oXHTTP.Open "GET", sURL, False
oXHTTP.send
GetSource = oXHTTP.responsetext
Set oXHTTP = Nothing

End Function


Tim
 
T

tx12345

That is a very nice bit of code. But what happens is a dialogue box pops
up with the source, and then after I click OK it goes away and never
gets into the worksheet.

Is there a way for the data to flow into the worksheet?


Many thanks

tx
 
T

tx12345

Hi Gary. Yes, that works, thank you.

What happens, though, is as much source as can be dumped into one cell
gets stuffed into A1, but somewhere down the middle of the source the
rest of it gets cut off.

Is there a way to get the import of the source to come in with the
carriage returns/line breaks?

If you import a web page, it fills up a1 to a1000 (or whatever), and
from there you can process the data, but if everything is in one cell
makes it more of a challenge.

Many Thx!

tx
 
T

tx12345

I came up with a solution (a hack)

open the source in a new file, then save it as a text file, then
re-open it and that shows the entire page. Apparently ithe page
contents are not cut off, just what excel can display inside of one
cell.

I did learn one thing: if you have text encapsulated with " " you can
fit a lotta text into one cell! The source comes in "<html> ...
</html>" If there is a way to get rid of the incoming quotes, I could
skp the hack I came up with, but if not i am still very apprecitive of
the tip.

As usual, everyone that helps me out gets a free copy of the file. -
you might not want it though, lol

Thanks again

tx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top