Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

vba (or other programming) for reading internet explorer webpages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
richardconers@yahoo.com - 27 Nov 2005 15:47 GMT
I have a large number of files saved as htm or html documents.  These
files (saved from the web with internet explorer as the browser) each
contain zillions of hyperlinks (which I don't need) and zillions of
embedded tables and other strange formatting.  Ideally, I'd like to be
able to read the infomation in the files and store the information in
Access (I am very proficient in Access VBA).

When I use Word to open the files, it takes forever for the document to
open, and even then, the information is basically unreadable because
the table configurations are incredibly screwed up.  The same thing
happens when I copy from the web browser (internet explorer) and paste
into Word.  I have also used getfromclipboard method, however, that
does not seem to preserve the columns, so the information is all
smashed together.

Is there any way to use VBA (without first opening the file via the
Word application) to
1) to open a web file as a web file [when i look at the
filescriptingobject in the vba help, it doesn't look like it has a file
open command)

2) use regular VBA commands such as setting range objects, collecting
information into string variables etc from this open web file ?

 For example, if the web page is the only Internet Explorer file open,
can VBA "access" that window/screen?  How can use (in VBA) something
like "Find" to find the data I'm looking for, and then move from column
to column reading the information?

Or what new language <sigh> do I have to learn to be able to do this
with web pages on the internet?
thank you!!!
Edward Thrashcort - 27 Nov 2005 17:34 GMT
Hi Richard

It took me a certain amount of blood, sweat and tears to find this out but
you can download a web page to file using this code below.  However, parsing
the file into usable data might not be easy!!

Eddie

Private Declare Function URLDownloadToFile Lib "urlmon" Alias
"URLDownloadToFileA" ( _
       ByVal pCaller As Long, _
       ByVal szURL As String, _
       ByVal szFilename As String, _
       ByVal dwReserved As Long, _
       ByVal lpfnCB As Long) As Long

Private Function WebToFile(szURL As String, szFilename As String) As Long
Dim pCaller As Long
   pCaller = 0
Dim dwReserved As Long
   dwReserved = 0
Dim lpfnCB As Long
   lpfnCB = 0

WebToFile = URLDownloadToFile(pCaller, szURL, szFilename, _
       dwReserved, lpfnCB)
End Function

Sub testWebToFile()
Dim xRetCode As Long
Dim sURL As String
Dim sFilename As String

sURL = "http://www.topwebsite.co.uk/metatags.shtml"
sFilename = "c:\temp\metatags.htm"

xRetCode = WebToFile(sURL, sFilename)
End Sub

> *From:* "richardconers@yahoo.com" <richardconers@yahoo.com>
> *Date:* 27 Nov 2005 07:47:34 -0800
[quoted text clipped - 31 lines]
> with web pages on the internet?
> thank you!!!

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.