Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

getting data from webpage that has frames

Posted on 2002-04-08
12
Medium Priority
?
311 Views
Last Modified: 2010-05-02
How can I, programmatically, get info from a table within the frame of a webpage?

Preece
0
Comment
Question by:Preece
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
12 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6926370
what kind of info do you need?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6926399
From where do you see that page?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6926418
with webbrowser component:
Add a reference to microsoft html object library
add a webbrowser component
Paste this code:


Dim ieDoc As HTMLDocument
Private Sub Form_Load()
wb1.Navigate "www.angelfire.com/realm/vb-shared/index.html"
End Sub


Private Sub wb1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is wb1.object) Then
    Dim i As Integer
    Dim tbl As Object
    Dim cell As IHTMLElement
    Set ieDoc = wb1.Document
    For i = 1 To ieDoc.frames.length
        For Each tbl In ieDoc.body.All
            If tbl.tagName = "TABLE" Then
                For Each cell In tbl.cells
                    Debug.Print cell.innerText
                Next
            End If
        Next tbl
   
    Next i
End If
End Sub
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 400 total points
ID: 6926424
To use with Internet explorer itself you need to add a reference to microsoft internet control instead of webbrowser control.

Dim ieDoc As HTMLDocument
dim withevents IE as InternetExplorer

Private Sub Form_Load()
set IE = new InternetExplorer
with ie
     .Navigate "www.angelfire.com/realm/vb-shared/index.html"
     .visible =true
end with
End Sub


Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is IE) Then
    Dim i As Integer
    Dim tbl As Object
    Dim cell As IHTMLElement
    Set IEdoc = IE.Document
    For i = 1 To ieDoc.frames.length
        For Each tbl In ieDoc.body.All
            If tbl.tagName = "TABLE" Then
                For Each cell In tbl.cells
                    Debug.Print cell.innerText
                Next
            End If
        Next tbl
   
    Next i
End If
End Sub
0
 
LVL 12

Author Comment

by:Preece
ID: 6926616
Hey, Richie:

I tried something like this and it worked:


    If webX.Document.frames.length > 0 Then
        Dim hDoc As HTMLDocument, i As Integer
        Set hDoc = webX.Document
        For i = 0 To hDoc.frames.length - 1
            For Each Tbl In hDoc.frames(i).Document.All
                  'do something
            next Tbl
        next i
    endif


Preece
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6928064
Two questions:
If your page hasn't frames, it doesn't read any table.
Where do you use that code? I suposse in Document_complete, right?
Your code is a little compact than mine. I did mine in a rush.
Be carefull, that code would enumerate .all tags, if you don't check whitch tag is....
Cheers
0
 
LVL 12

Author Comment

by:Preece
ID: 6929506
Hey Richie,

First of all, I want to thank you for all of the help that you have given in the past.  I say, you must be paid to answer EE Q's all day!  I'd like that job!  

1)  "If your page hasn't frames, it doesn't read any table..."
I am gathering info from a number of sites, one of which uses a frameset.  So I use this code on that particular page.  

2)  I first use a WebBrowser control and navigate to a web site.  I then pass the  WebBrowser control (webX) to the code that you see above.  Then I loop thru the frames and tables, inspecting each table for the presence of a value in a particular cell.  Once that value is found, then I extract the values from the target table!  I don't even bother with tags, as some pages that I use don't have tags on the tables!

Preece
0
 
LVL 12

Author Comment

by:Preece
ID: 6929514
also, I have Tbl defined as an HTMLTable
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6929569
Yeah, thank you! I remember you.
Regarding HTMLTable (and other html elements). Sometimes, all collections doesn't manage very well for each ... loops for some reason that i hadn't time to know why.
I had to face a time ago with that problem, all col returns all tags and sometimes the loop asign a value to tbl (as in this example) which is not a table at all and the code is messed up!
0
 
LVL 12

Author Comment

by:Preece
ID: 6929645
It's amazing how creative you can get with the use of error handlers!

Preece
0
 
LVL 12

Author Comment

by:Preece
ID: 7241752
Thanks Richie!  Sorry it took so long to get back to this question.  Also, I have another if you wouldn't mind taking a look!  

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20337204.html

Thanks again!
Preece
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7243171
Thanks for "A" grade.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

704 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