In my Excel vba I try to fill an input field of a web page form, but get always "Automation Error-Interface not found". The input field's id is "network" that I can easily get from the html source. My code is:
Sub OpenWebPage()
Dim ie As Object
Dim url As String
' Create Internet Explorer object
Set ie = CreateObject("InternetExplorer.Application")
' Set the URL
url = "https://rb-ddi.ddi.bosch.com/netsearch.html"
' Make the browser visible
ie.Visible = True
' Navigate to the URL
ie.Navigate url
' Wait for the page to load
Application.Wait (Now + TimeValue("00:00:10")) ' Wait 10 seconds to be sure that page is opened
' Find the input field by its ID and fill it with a value
Set networkInput = ie.document.getElementById("network") 'here get the error
If Not networkInput Is Nothing Then
networkInput.value = "YourNetworkValue" ' Replace with the network value you want to enter
End If
' Cleanup
Set ie = Nothing
End Sub
I get the error at the line
Set networkInput = ie.document.getElementById("network")
I have tried instead of getElementById also getElementByTagName and getElementByName.
The html part where the input field is:
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Network</label>
<div class="col-md-9 col-sm-9 col-xs-12">
<input type="text" class="form-control" placeholder="Network Address" id="network" list="networksearch" autocomplete="off">
<datalist id="networksearch">
</datalist>
</div>
</div>
getElementByTagNameandgetElementByName" - both of those have typos? Are you able to read/access anything on the page from VBA?