Consulting

Results 1 to 3 of 3

Thread: How to get the data from website (javascript) to excel by using vba

  1. #1
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location

    How to get the data from website (javascript) to excel by using vba

    The Website:

    <trclass="abc">
    <td><inputname=" 01$ColumnAllSelector"type="checkbox" id=" 01_ColumnAllSelector"onclick="RowSelectorColumn_SelectAll( this );"/></td><td>StartDay</td><td>End Day</td><td>Numbers</td><td>Item</td>
    <td>price</td><td>unit</td><td>qty</td><td> subtotal</td><td>remarks</td><td>Status</td><td>Name /td>

    </tr><trclass="Row3">
    <td><inputname="02$ColumnSelector"type="checkbox" id=" 02_ColumnSelector"onclick="RowSelectorColumn_CheckChildren( ' 01_ColumnAllSelector');" />
    <script language='javascript'>
    RowSelectorColumn_Register('01_ColumnAllSelector','02_ColumnSelector')
    </script></td><td>01-01-2011</td><td>31-01-2011</td><td>0001</td><td>type1</td><td>$5,000.00</td><td>month</td><td>1</td><td>
    $5,000</td><td>car rent</td><td>Finish</td><td>Chris Wong</td>

    </tr><trclass="Row1">
    <td><inputname=" 03$ColumnSelector"type="checkbox" id="03_ColumnSelector"onclick="RowSelectorColumn_CheckChildren( ' 01_ColumnAllSelector');" />
    <script language='javascript'>
    RowSelectorColumn_Register('01_ColumnAllSelector','03_ColumnSelector')
    </script></td><td>01-02-2011</td><td>29-02-2011</td><td>0002</td><td> type2</td><td>$3,500.00</td><td>month</td><td>2</td><td>
    $7,000</td><td>car rent</td><td>Finish</td><td>Amy Chan</td>

    </tr><trclass="Row3">
    <td><inputname=" 04$ColumnSelector"type="checkbox" id=" 04_ColumnSelector"onclick="RowSelectorColumn_CheckChildren( ' 01_ColumnAllSelector');" />
    <script language='javascript'>
    RowSelectorColumn_Register('01_ColumnAllSelector','04_ColumnSelector')
    </script></td><td>01-02-2012</td><td>28-02-2012</td><td>0003</td><td> type1</td><td>$5,000.00</td><td>month</td><td>3</td><td>
    $15,000</td><td>car rent</td><td>Not Yet Finish</td><td>Eric Chan</td>

    </tr><trclass="Row1">
    <td><inputname=" 05$ColumnSelector"type="checkbox" id="05_ColumnSelector"onclick="RowSelectorColumn_CheckChildren( ' 01_ColumnAllSelector');" />
    <script language='javascript'>
    RowSelectorColumn_Register('01_ColumnAllSelector','05_ColumnSelector')
    </script></td><td>01-02-2011</td><td>29-02-2011</td><td>0002</td><td> type2</td><td>$3,500.00</td><td>month</td><td>2</td><td>
    $7,000</td><td>car rent</td><td>Finish</td><td>Amy Chan</td>

    [/HTML]


    Sub Sample()
        Dim objIe As Object, xobj As HTMLDivElement
        Set objIe = CreateObject("InternetExplorer.Application")
        objIe.Visible = True
        objIe.navigate "http://www.abc.com"
        While (objIe.Busy Or objIe.READYSTATE <> 4): DoEvents: Wend
    
        Set xobj = objIe.Document.getElementById("")
        Set xobj = xobj.getElementsByClassName("").Item(0)
        Set xobj = xobj.getElementsByClassName("")(0)
    
        Sheets("Sheet1").cell(1, 1) = xobj.innerText
        Set xobj = Nothing
        objIe.Quit
        Set objIe = Nothing
    
    End Sub

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    I couldn't find the website you are referring to.

  3. #3
    VBAX Contributor
    Joined
    Nov 2009
    Posts
    114
    Location
    Thanks!
    This is only the structure of web. I just don't know how
    to use these code to get data from this structure of web
    to excel worksheet.

    Set xobj = objIe.Document.getElementById("")
    Set xobj = xobj.getElementsByClassName("").Item(0)
    Set xobj = xobj.getElementsByClassName("")(0)

Posting Permissions

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