VBA - Code Error 91

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
840
I am getting error code 91 on the line

Code:
ActiveWorkbook.Sheets("Sheet1").Range("A1").Value = holdingsClass(0).textContent

Any reason please? Thanks.

Code:
Sub Pull_Data()


Dim IE As InternetExplorer
Dim html As HTMLDocument


Set IE = New InternetExplorer
IE.Visible = False
IE.navigate "http://greyhoundbet.racingpost.com/#meeting-list/view=time&r_date=2018-02-16"


'Wait until IE is done loading page
Do While IE.readyState <> READYSTATE_COMPLETE
DoEvents
Loop


'Get Data
Set html = IE.document
Set holdingsClass = html.getElementsByClassName("appList raceList raceListTime")
ActiveWorkbook.Sheets("Sheet1").Range("A1").Value = holdingsClass(0).textContent


'Quit and clean
IE.Quit
Set IE = Nothing


End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hello James,

I think you misunderstood what this HTML function does...
Code:
Set holdingsClass = html.getElementsByClassName("appList raceList raceListTime")

This function does not take an array of arguments, rather it returns an array of all HTML elements that have a single Class name.
Code:
Set holdingsClass = html.getElementsByClassName("appList")
 
Upvote 0
Hello James,

I think you misunderstood what this HTML function does...
Code:
Set holdingsClass = html.getElementsByClassName("appList raceList raceListTime")

This function does not take an array of arguments, rather it returns an array of all HTML elements that have a single Class name.
Code:
Set holdingsClass = html.getElementsByClassName("appList")


Thanks, I am really a newbie at pulling data via HTML, is there any literature on this please?
 
Upvote 0
Hello James,

There is an excellent site I have used a lot and have bookmarked W3Schools They have examples, references, and tutorials available for HTML, CSS, JavaScript, SQL, and some other languages.
 
Upvote 0
HEllo James,

Sorry, you did ask about pulling HTML data using VBA. I personally don't know of any sites that provide tutorials how to do this using VBA. Others here might know and post some links for you.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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