VBA - Code Error 91

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
669
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
 

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,869
Office Version
2010, 2007
Platform
Windows
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")
 

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
669
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?
 

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,869
Office Version
2010, 2007
Platform
Windows
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.
 

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
669
thanks, this doesnt appear to tell you how to vba pull html from the web though?
 

Leith Ross

Well-known Member
Joined
Mar 17, 2008
Messages
1,869
Office Version
2010, 2007
Platform
Windows
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.
 

Forum statistics

Threads
1,082,278
Messages
5,364,201
Members
400,786
Latest member
ismi88

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top