Home Excel VBA - Copy table data from website and put into excel?
Reply: 0

Excel VBA - Copy table data from website and put into excel?

user1399
1#
user1399 Published in April 20, 2018, 10:51 am

I am trying to copy a table from a website and put this into excel. My table can be identified by the elementID "VisibleReportContentctl32".

For some reason, my code produces this error: 'object required'

on this line: Range("A1").Text = dat

Here's my full code:

Option Explicit
Public Sub GetSSRSData()

    Dim IE            As Object: Set IE = New InternetExplorerMedium
    Dim TR_Elements   As Object
    Dim TR            As Object ' Table Row
    Dim TD_Elements   As Object
    Dim TD            As Object ' Table Data
    Dim RowNumb       As Integer
    Dim Columns       As Integer
    Dim ColumnNumb    As Integer
    Dim x As Integer
    Dim dat As String

    With IE
        .Visible = True
        .Navigate ("http://gbrlon02-sql-17/Reports/Pages/Report.aspx?ItemPath=%2fCutlass+Reports%2fManagement+Reporting%2fForwardOrdersSticksOnly+-+ForecastVariance+(Monthly+Report)")

         Do While IE.Busy Or IE.ReadyState <> 4
             DoEvents
         Loop

         If IsObject(.Document.getElementById("VisibleReportContentctl32_ctl09")) Then
            dat = IE.Document.getElementById("VisibleReportContentctl32_ctl09").innerHTML
            Range("A1").Text = dat
         Else
            MsgBox "doesn't"
         End If
   End With
End Sub

please can someone show me where I am going wrong?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.30277 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO