Automate editing a field that takes value from a suggester

Viewed 17

I tried automating a task on my CRM (using VBA on IE) where there is a field that prompts a suggester as soon as you start typing in it. Even if I enter the exact intended text, the script doesn't save the changes.

Here is the HTML code of the field to be edited:

<input class="itext" size="40" id="txtStrPoblacion" onkeyup="searchPoblacion(this.form, true);" autocomplete="off" value="Sector 14, Gurgaon, Gurgaon" type="text">

And, here is the script that I wrote:

Sub L3()

Dim IE As Object
Dim i As Long
Dim doc As HTMLDocument
Dim oHTML_Element As IHTMLElement

Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True
For i = 2 To 2
IE.navigate "https://in.nuptic.com/admin/admin-ModificarEmpresa.php?id_empresa=" + Cells(i, 2)

Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop


Set doc = IE.document

doc.getElementById("txtStrPoblacion").Value = Cells(i, 3)

With IE.document

        Set elems = .getElementsByTagName("input")
        For Each e In elems

            If (e.getAttribute("value") = "Save") Then
                e.Click
                Exit For
            End If

        Next e

    End With

Next
MsgBox "Done"
End Sub
0 Answers
Related