0

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>
5
  • 1
    Which line throws the error? Which browser does the script open (IE or Edge)? Commented Apr 4 at 14:04
  • @Shrotter I get the error at line Set networkInput = ie.document.getElementByTagName("network") . Have also just added to the question Commented Apr 4 at 14:05
  • Possibly that page doesn't support IE? Commented Apr 4 at 16:35
  • @TimWilliams The page is opening with ie. When i enter ip manually and press button in ie correct result is given Commented Apr 4 at 17:46
  • "getElementByTagName and getElementByName" - both of those have typos? Are you able to read/access anything on the page from VBA? Commented Apr 4 at 18:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.