Getting Data From a web site into Excel

ercedwards

Board Regular
Joined
Apr 27, 2013
Messages
125
I have the following macro which has worked for ages until the web page format changed.

Now, this macro still pulls most of the data but doesn't retrieve the real data I need which is the actual fire runs below the headings.

Can anyone help. You can drop this macro into any blank workbook to see what I mean.

Thanks much.

Code:
Sub Download()
    Worksheets("CADScreen").Select
    On Error GoTo CADDown
    Application.ScreenUpdating = False
    Range("A:AZ").Select
    Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;https://www.toronto.ca/community-people/public-safety-alerts/alerts-notifications/toronto-fire-active-incidents/#main", Destination:=Range("$A$1"))
        .Name = "TFSCad"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = False
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
         Range("A1").Select
    End With
    GoTo CADOK
CADDown:
    Range("A1") = "CAD is Down"
    GoTo Done
CADOK:
     Range("J1") = ""
    Application.ScreenUpdating = True
Done:
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Looks like the data is no longer in an actual table but wrapped in an iframe or something so your code is grabbing everything outside that wrapper. Go to page with a browser and view source
 
Upvote 0
Roderick,

I'm a real rookie at this. I looked at the source and it looks like what I need is in a table.
What is really strange is that if I go to the web page, right click and select all then copy and paste into my worksheet, everything is fine.
If I use ExecWB 17 to select all and ExecWB 12 to copy, the data I want isn't copied. I thought ExecWB 17 was supposed to work.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top