Solved

vb read table from IE web page

Posted on 2006-07-16
1
393 Views
Last Modified: 2008-02-01
Hi,
     I wrote this piece of code to connect to explorer, open a webpage, and copy data from there by searching for a field name...What is the easiest or efficient way to copy data from a table located on a web page ?

Dim oIE, oIEDoc
Dim aInput As Variant
'Create the IE Application object
Set oIE = CreateObject("InternetExplorer.Application")
oIE.Visible = True

'Load page with data
oIE.Navigate ("http://172.20.41.11/test/FGPH_Detail.asp?varCrit=test-1Z&submit1=Submit+Query")
'Wait for page to load
Do While (oIE.ReadyState <> 4)
Loop

'Capture the IE document
Set oIEDoc = oIE.document
Set oBody = oIEDoc.Body
'Field Name
Text = "Customer Name"
dietype = InStr(oBody.innerText, Text)

oIE.Quit
Set oIE = Nothing
0
Comment
Question by:azcalv408
1 Comment
 
LVL 4

Accepted Solution

by:
jomacinc earned 50 total points
ID: 17120695
I would use the Internet Transfer Control to get the full HTML source of the page, you can then use string manipulation to extract the parts you need. This would save you the massive overhead of loading IE (uses far too much memory and processor time for the basic purpose it serves).

Presuming you had an Internet Transfer Control on yourt form called "Inet1":

'-----------------------------------------------------------------------------------
    Dim sHTMLSource  As String
    sHTMLSource = Inet1.OpenURL("http://www.someurl.here", icString)
'-----------------------------------------------------------------------------------

Regards, Jomac.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now