IE Automation in VBA

chadcollings

Board Regular
Joined
Oct 13, 2009
Messages
82
Afternoon,

I am trying to automate some IE navigation. I am running into an issue when trying to populate a field. The object will allow for text entry - but i cannot seem to find a way to fire/trigger an event to populate the dropdown list that will then allow me to select from their "approved" list items.

When i get to the point of "clicking" the button, it will error out the location object.

I have commented out the line having the issue

I am using Office 2016 32 bit on a Windows 10 Machine.

Any help would be GREATLY appreciated. As i have been beating my head against this all day.

Code:
''REFERENCES - Microsoft Scripting Runtime

Sub Car_Check()
Dim objIE As Object
Set objShell = CreateObject("Shell.Application")
Set objAllWindows = objShell.Windows

On Error GoTo ErrHandler

TargetURL = "https://www.costcotravel.com/h=4005"
Set objIE = New InternetExplorerMedium
objIE.navigate TargetURL

Do While objIE.readyState <> 4 Or objIE.Busy
    DoEvents
Loop

objIE.document.getElementById("pickupLocationTextWidget").Focus


''-------------------------------cant fire event to select drop down options
objIE.document.getElementById("pickupLocationTextWidget").Value = "(MCO) Orlando International , FL"
''-------------------------------
objIE.document.getElementById("pickUpDateWidget").Value = "08/31/2019"
objIE.document.getElementById("pickupTimeWidget").Value = "05:00 PM"
objIE.document.getElementById("dropOffDateWidget").Value = "09/12/2019"
objIE.document.getElementById("dropoffTimeWidget").Value = "06:00 AM"

objIE.document.getElementById("findMyCarButton").Click

Exit Sub

''Find Window when IE window is lost
ErrHandler:
For Each ow In objAllWindows
    If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
        I = 0
        If ow = "Internet Explorer" Then
            Set objIE = ow
        End If
    End If
Next
Resume

End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Watch MrExcel Video

Forum statistics

Threads
1,129,735
Messages
5,638,064
Members
417,001
Latest member
MSteel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top