saving .doc as .txt w/VBA from browser

tx12345

Board Regular
Joined
Aug 28, 2006
Messages
165
Hi

Using VBA, i can go to a htm page, grab the text, and so on. but when going to a certain URL it opens a word doc in the browser. the link changes from .htm to .doc

what i'd like to do is save this doc as a .txt file or just grab the text.

TIA

tx
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Code:
Option Explicit
Sub EarlyBoundExample()
'Requires reference to the Microsoft Internet Controls
'Requires reference to Microsoft Word xx.x object Library
Const strURL As String = "http://www.lancs.ac.uk/staff/msacfj/MSC%20VBA%20Course%20Outline.doc"
Dim IE As SHDocVw.InternetExplorer
Dim doc As Word.Document
Set IE = New InternetExplorer
IE.Navigate strURL
Do Until IE.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Set doc = IE.Document
MsgBox doc.Range.Text
IE.Quit
End Sub
Sub LateBoundExample()
Const strURL As String = "http://www.lancs.ac.uk/staff/msacfj/MSC%20VBA%20Course%20Outline.doc"
Dim IE As Object
Dim doc As Object
Set IE = VBA.CreateObject("InternetExplorer.Application")
IE.Navigate strURL
Do Until IE.ReadyState = 4
DoEvents
Loop
Set doc = IE.Document
MsgBox doc.Range.Text
IE.Quit
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,269
Messages
6,183,960
Members
453,198
Latest member
VB6 Programming

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