'MS Access Web Scraping -vba runtime error 91
I have a small MS Access (Office 365) program to perform web page scrapes and store the results in Access tables. The program looks up a web page then reads in any menu links. However, when trying to do this I keep receiving the error:
Object variable not set (Error 91)
And this line gets highlighted:
Set arrAreas = vDiv.getElementsByClassName("rmLink rmRootLink")
This is the full code:
Private Function fx_Read_List()
'------------< fx_Read_List() >------------
'< get Menu >
Dim vDiv As HTMLDivElement
Set vDiv = hdoc.getElementById("ctl00_ctlMenu")
'< get Menu-Area Links >
Dim arrAreas As IHTMLElementCollection
Set arrAreas = vDiv.getElementsByClassName("rmLink rmRootLink")
'</ get Menu-Area Links >
'< save in Array >
Dim arrLinks() As String
ReDim arrLinks(100)
Dim iLink As Integer
For iLink = 0 To arrAreas.length - 1
Dim aLink As HTMLAnchorElement
Set aLink = arrAreas(iLink)
arrLinks(iLink) = aLink.hRef
Next
ReDim Preserve arrLinks(iLink - 1)
'</ save in Array >
What am I missing?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
