Forum Discussion
VBA troubleshooting: "Object variable or With block variable not set" How do I fix this?
Hey guys,
I am trying to fill-in data in a website with VBA, but I am getting a run time error 91. I have the idea that there is an error due to auto-complete, but I am not 100% sure.
The website is to calculate travel time, the value is (Dutch) travel data.
Who can help me?
VBA Code:
--------------------------------------------------------------------------------------
Sub GetHTMLDocument()
Dim IE As New SHDocVw.InternetExplorer
Dim HTMLDoc As MSHTML.HTMLDocument
Dim HTMLInput As MSHTML.IHTMLElement
Dim HTMLButtons As MSHTML.IHTMLElementCollection
Dim HTMLButton As MSHTML.IHTMLElement
IE.Visible = True
IE.navigate "https://www.anwb.nl/verkeer/routeplanner"
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
Set HTMLDoc = IE.Document
Set HTMLInput = HTMLDoc.getElementById("routing-input-address-field-0")
HTMLInput.Value = "9711NA"
End Sub
-----------------------------------------------------------------------------------
Gijs1 please start your own thread. Feel free to message me the link. Also, your code looks fine and you shouldn't be getting that error. You would, however, need two references (Tools > References...) Microsoft HTML Object Library and Microsoft Internet Controls.