Results 1 to 3 of 3

Thread: Fill detail in search box on website

  1. #1

    Fill detail in search box on website

    Hello Everyone,

    Can anyone help me on below situation

    i want to give detail in search box on the webpage, but once open the website i am getting error and not filling text in searchbox, below code which i am using.

    Sub lookupTest()
        Dim appIE As InternetExplorerMedium
        'Set appIE = Nothing
        Dim objElement As Object
        Dim objcollection As Object
        Set appIE = New InternetExplorerMedium
        sURL = ""
        With appIE
            .Navigate sURL
            .Visible = True
            Do While appIE.Busy Or appIE.ReadyState <> 4
        End With
        Set objcollection = appIE.Document.getElementsByTagName("input")
        i = 0
        While i < objcollection.Length
            If objcollection(i).id = "MscrmControls.Containers.RelevanceSearchControl-text-input-props" Then
                ' Set text for search
                objcollection(i).Value = "12345"
            End If
            Do While appIE.Busy Or appIE.ReadyState <> 4
            i = i + 1
        Set appIE = Nothing
        MsgBox (done)
    End Sub

    Element code is
    "<input id="MscrmControls.Containers.RelevanceSearchControl-text-input-props" aria-label="Search box" data-id="MscrmControls.Containers.RelevanceSearchControl-text-input-props" placeholder="Search Dynamics 365 data" autocomplete="off" type="text" class="iq ct lt lu lv lw do lx if " value="">"

  2. #2
    VBAX Newbie
    Feb 2024
    Some problems can occur:

    Element id: Ensure that the id "MscrmControls.Containers.RelevanceSearchControl-text-input-props" is correct and has not been changed by other JavaScript code after the web page is loaded.
    Timeout: Make sure you wait until the web page has finished loading before attempting to fill in the search box.
    Error checking: Consider printing out the value of objcollection(i).id to ensure that you are selecting the correct element.
    Check access: Sometimes accessing elements on a website requires access or authentication.
    Check the above conditions to review and correct errors in your code.

  3. #3
    Make certain once the page loads, the id "MscrmControls.Containers.RelevanceSearchControl-text-input-props" is accurate and hasn't been altered by any other JavaScript code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts