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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically Saving a Web Page as a Text File

Status
Not open for further replies.

marcusw

Programmer
Jan 18, 2001
35
GB
Hi,

Does anyone have any ideas how I can navigate to a URL and save it as Text File. Essentially, I want to do a File¦Save As¦C:\temp\abc.txt although automatically in VB.

It's important that the file gets saved as a true text file rather than a saved HTM file as .txt. I don't want all the HTML... just a saved txt intepretation of the htm file.

I'm currently using an API (URLDownloadToFileA) but this saves as a htm file.

Anyone help?

Cheers,

Marcus.
 
Here are 3 possibilities, however, with each one you will need to down load the page to a WebBrowser control first

Hope it helps

Grant

'text of document, no html
MsgBox WebBrowser1.Document.body.innerText

'text of document, with html
MsgBox WebBrowser1.Document.Script.Document.body.outerhtml

'text of document, no html - generated by first selecting the text
WebBrowser1.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
MsgBox WebBrowser1.Document.selection.createRange.Text
 
Thanks Grant,

One problem, the reference to "WebBrowser1.Document.body.innerText" gives 'object variable or With Block variable not set'. Can you expand a bit further on this please? Could you post some example code if you've got some please. This is the first time I've used the WebBrowser control.

Cheers,

Marcus.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top