Results 1 to 21 of 21

Thread: [Resolved] Webbrowser - MSHTML Library - Why Late Bound?

Threaded View

  1. #1

    Thread Starter
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Resolved [Resolved] Webbrowser - MSHTML Library - Why Late Bound?

    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:
    1. Option Explicit
    2. Private Sub Command1_Click()
    3.     Dim i As Long, j As Long
    4.     Dim WebDoc As MSHTML.HTMLDocument
    5.     Dim MyTbl As MSHTML.IHTMLTable2
    6.     Dim MyTblR As MSHTML.IHTMLTableRow2
    7.    
    8.     'Navigate to the page and wait until fully loaded in the webbrowser
    9.     WebBrowser1.Navigate2 "http://nitpu3.kar.nic.in/blrcustoms/pn_2005.htm"
    10.     Do While WebBrowser1.ReadyState <> READYSTATE_COMPLETE
    11.         DoEvents
    12.     Loop
    13.    
    14.     For Each MyTbl In WebBrowser1.Document.getElementsByTagName("table")
    15.         If MyTbl.cells.length > 4 Then
    16.             If Trim(MyTbl.cells(0).[B]innerText[/B]) = "Public Notice No" _
    17.                And Trim(MyTbl.cells(1).[B]innerText[/B]) = "Issue Date" _
    18.                And Trim(MyTbl.cells(2).[B]innerText[/B]) = "Subject" Then
    19.                     ''This is the table I was looking for
    20.                     Exit For
    21.             End If
    22.         End If
    23.     Next
    24.     Set MyTblR = MyTbl.moveRow(0)
    25.     Dim ub As Long
    26.     ub = MyTbl.cells.length \ MyTblR.[B]cells.length[/B] - 2
    27.     For i = 0 To ub
    28.         Set MyTblR = MyTbl.moveRow(0)
    29.         For j = 0 To MyTblR.[B]cells.length [/B] - 1
    30.             Debug.Print MyTblR.[B]cells(j).innerText[/B],
    31.         Next
    32.         Debug.Print
    33.     Next
    34.     MsgBox "Done"
    35. 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
    Last edited by Pradeep1210; May 20th, 2005 at 01:54 AM. Reason: Problem resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width