How do you automatically update data in a word doc from a wesite?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a newsletter and use data from the same websites each day. Is
there a way I can link this information to update automatically when I open
the word document?
 
The subroutine below goes to the Comcast home page, captures the html as
text, locates the user's temp file and creates an htm file in the temp
folder with the contents from the Comcast page. Pictures and other linked
objects are not copied to this htm file so the appearance is quite different
than the actual web page but you may be able to use the html tags as
reference marks and extract the data to your Word document. When you
complete the operation, you would want to write a line to delete the
temporary htm file created to keep the junk in your temp folder limited.

Steve Yandl

Sub CheckWebPage()

On Error Resume Next

Const ForWriting = 2

strURL = "http://www.comcast.net/comcast.html"

Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", strURL, False
objHTTP.Send

Set objFSO = CreateObject("Scripting.FileSystemObject")

' Locate path to temp folder
tmpPath = objFSO.GetSpecialFolder(2)

' Create text file, SiteA.htm in Temp folder
Set objFile = objFSO.CreateTextFile(tmpPath & "\SiteA.htm", ForWriting)
objFile.Write objHTTP.ResponseText
objFile.Close

End Sub
 

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

Back
Top