Hello everyone,
I'm trying to create a macro to auto fill a form for me. There is a field called agent name. It requires one to place the agents ID, click find, and select them from a list. I am using their ID, so the "list" actually only contains one value. Even though its the only agent in the list, you must select the agent name from the list. I've included the HTML snip it of the list, and my code below
****HTML****
<ul tabindex="0" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" style="left: 184.92px; top: 220px; width: 263px; display: none;"><li tabindex="-1" class="ui-menu-item" id="ui-id-3">Last Name, First Name (1234567/7654321) </li></ul>
<li tabindex="-1" class="ui-menu-item" id="ui-id-3">Last Name, First Name (1234567/7654321) </li>
</ul>
***VBCODE***
Sub TrackerAutoFill()
'Creates a Sub called TrackerAutoFill
Dim ie As Object
'set ie as an object
Set ie = CreateObject("internetexplorer.application")
'sets ie to the internet explorer applicaton
With ie
.Visible = True
.navigate "OURWEBFORMPAGE"
'opens the ie object and navigates to the tracking page
Do While .busy
DoEvents
Loop
Do While .readystate <> 4
DoEvents
Loop
'provides time for ie to open, and waits for the page to load.
Set agentname = .document.getelementbyid("txtReceivedBy")
agentname.Value = "7654321"
.document.getelementbyid("btnReceivedBy").Click
Do While .busy
DoEvents
Loop
Do While .readystate <> 4
DoEvents
Loop
Set agentselection = .document.getelementbyid("ui-id-1")
agentselection.ListIndex = agentselection.ListCount - 1
End With
End Sub
I'm trying to create a macro to auto fill a form for me. There is a field called agent name. It requires one to place the agents ID, click find, and select them from a list. I am using their ID, so the "list" actually only contains one value. Even though its the only agent in the list, you must select the agent name from the list. I've included the HTML snip it of the list, and my code below
****HTML****
<ul tabindex="0" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content" id="ui-id-1" style="left: 184.92px; top: 220px; width: 263px; display: none;"><li tabindex="-1" class="ui-menu-item" id="ui-id-3">Last Name, First Name (1234567/7654321) </li></ul>
<li tabindex="-1" class="ui-menu-item" id="ui-id-3">Last Name, First Name (1234567/7654321) </li>
</ul>
***VBCODE***
Sub TrackerAutoFill()
'Creates a Sub called TrackerAutoFill
Dim ie As Object
'set ie as an object
Set ie = CreateObject("internetexplorer.application")
'sets ie to the internet explorer applicaton
With ie
.Visible = True
.navigate "OURWEBFORMPAGE"
'opens the ie object and navigates to the tracking page
Do While .busy
DoEvents
Loop
Do While .readystate <> 4
DoEvents
Loop
'provides time for ie to open, and waits for the page to load.
Set agentname = .document.getelementbyid("txtReceivedBy")
agentname.Value = "7654321"
.document.getelementbyid("btnReceivedBy").Click
Do While .busy
DoEvents
Loop
Do While .readystate <> 4
DoEvents
Loop
Set agentselection = .document.getelementbyid("ui-id-1")
agentselection.ListIndex = agentselection.ListCount - 1
End With
End Sub