I'm having trouble getting the value from an input field called "due date"
Here is my HTML and VBA code.
I resolved error 462, but I can't retrieve certain data.
Actually I'm getting an error: Run-time error '91: Object variable or With block variable not set
VBA:
Sub Dane_z_www()
Range("A1").Clear
Dim appIE As InternetExplorerMedium
Dim my_url As String
Dim TerminPlatnosci As String
Dim shellWins As SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer
Dim Doc As HTMLDocument
my_url = "https://example.com"
Set appIE = New InternetExplorerMedium
With appIE
.Visible = True
.Navigate my_url
End With
Set shellWins = New SHDocVw.ShellWindows
For Each IE In shellWins
If IE.Name = "Internet Explorer" Then
Set IEObject1 = IE
Debug.Print IE.LocationURL
Debug.Print IE.LocationName
End If
Next
Set shellWins = Nothing
Set IE = Nothing
Do While appIE.Busy Or appIE.ReadyState <> 4
DoEvents
Loop
Set Doc = appIE.Document
'TerminPlatnosci = Trim(Doc.getelementsByName("section-36-control$xf-771$xf-784$xml_termin_platnosci-control$xforms-input-1")(0).Value)
'TerminPlatnosci = Trim(Doc.getElementsByTagName("tr")(0).getElementsByName("input id")(0).getAttribute("value"))
TerminPlatnosci = Trim(Doc.querySelector("input[name='section-36-control$xf-771$xf-784$xml_termin_platnosci-control$xforms-input-1']").getAttribute("value"))
Range("A1").Value = TerminPlatnosci
appIE.Quit
Set appIE = Nothing
MsgBox "Daty zostały wczytane", , "Komunikat"
End Sub
HTML:

The code provides three variants that I used when trying to download the data.
TerminPlatnosci = Trim(Doc.getelementsByName("section-36-control$xf-771$xf-784$xml_termin_platnosci-control$xforms-input-1")(0).Value)
TerminPlatnosci = Trim(Doc.getElementsByTagName("tr")(0).getElementsByName("input id")(0).getAttribute("value"))
TerminPlatnosci = Trim(Doc.querySelector("input[name='section-36-control$xf-771$xf-784$xml_termin_platnosci-control$xforms-input-1']").getAttribute("value"))
Range("A1").Value = TerminPlatnosci
Object variable or With block variable not set?getAttributeorTrim, save the results ofDoc.querySelectorinto a variable so you can check to make sure it returned something first. You can't get attributes from something it cannot find.