I m working on a project that extracts the table data from webpages.
I have observed that many properties and methods of the MSHTML library are late bound and I need to discover their names myself.
For e.g. See the code below. Add a Command Button, a WebBrowser control and refrence to Microsoft HTML Object Library. It is working perfectly OK. It extracts teh table elements and prints it to the debug window.
VB Code:
Option Explicit Private Sub Command1_Click() Dim i As Long, j As Long Dim WebDoc As MSHTML.HTMLDocument Dim MyTbl As MSHTML.IHTMLTable2 Dim MyTblR As MSHTML.IHTMLTableRow2 'Navigate to the page and wait until fully loaded in the webbrowser WebBrowser1.Navigate2 "http://nitpu3.kar.nic.in/blrcustoms/pn_2005.htm" Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE DoEvents Loop For Each MyTbl In WebBrowser1.Document.getElementsByTagName("table") If MyTbl.cells.length > 4 Then If Trim(MyTbl.cells(0).[B]innerText[/B]) = "Public Notice No" _ And Trim(MyTbl.cells(1).[B]innerText[/B]) = "Issue Date" _ And Trim(MyTbl.cells(2).[B]innerText[/B]) = "Subject" Then ''This is the table I was looking for Exit For End If End If Next Set MyTblR = MyTbl.moveRow(0) Dim ub As Long ub = MyTbl.cells.length \ MyTblR.[B]cells.length[/B] - 2 For i = 0 To ub Set MyTblR = MyTbl.moveRow(0) For j = 0 To MyTblR.[B]cells.length [/B] - 1 Debug.Print MyTblR.[B]cells(j).innerText[/B], Next Debug.Print Next MsgBox "Done" End Sub
The problem is -
1. The Items in bold don't appear after pressing dot(.), though at runtime they run perfectly OK. They seem to be late bound, though I have declared the variables correctly and set references correctly. Why is it late bound then?
2. I need to discover the properties and methods myself by hit and trial. That's quite a tedious and unreliable thing. Can someone provide me the complete list of methods and properties or a link where I can get these?
Thanks in advance !
Pradeep




Reply With Quote