dversloot1
Board Regular
- Joined
- Apr 3, 2013
- Messages
- 113
Hello!
I've found some code online that I've altered to work with my product link however the product price isn't being pulled. The error returned is "Object variable or with block variable not set"
The msgbox should show 18.98
Sub GetProductPricing()
Dim ie As InternetExplorer
Dim doc As HTMLDocument
Dim prc As Object
Dim prodPrice As String
Set ie = New InternetExplorer
With ie
.navigate "https://www.homedepot.ca/en/home/search.html?q=790209"
.Visible = True
Do While .readyState <> 4: DoEvents: Loop
Set doc = ie.document
With doc
Set prc = .querySelectorAll("[itemprop=price]")(0)
If Not prc Is Nothing Then
prodPrice = prc.getElementsByTagName("price")(0).innerText
Else
prodPrice = "Price not available"
End If
End With
End With
ie.Quit
MsgBox prodPrice
End Sub
I've found some code online that I've altered to work with my product link however the product price isn't being pulled. The error returned is "Object variable or with block variable not set"
The msgbox should show 18.98
Sub GetProductPricing()
Dim ie As InternetExplorer
Dim doc As HTMLDocument
Dim prc As Object
Dim prodPrice As String
Set ie = New InternetExplorer
With ie
.navigate "https://www.homedepot.ca/en/home/search.html?q=790209"
.Visible = True
Do While .readyState <> 4: DoEvents: Loop
Set doc = ie.document
With doc
Set prc = .querySelectorAll("[itemprop=price]")(0)
If Not prc Is Nothing Then
prodPrice = prc.getElementsByTagName("price")(0).innerText
Else
prodPrice = "Price not available"
End If
End With
End With
ie.Quit
MsgBox prodPrice
End Sub