IMEXCELING
New Member
- Joined
- Jul 18, 2015
- Messages
- 7
Hi Gang.
Need support with a macro to populate a webpage. I'm new to VBA and can't seem to figure out how to solve this.
When complete, the macro should:
Open internet explorer
go to a specific web page
enter in a postal code
click on the next page
wait 10 seconds to load
enter in a year
enter in a vehicle make
enter in a vehicle model
etc.
The problem i'm having is that the "vehicle make" has a dropdown "list box selections: that affect the "vehicle model" and I can't get vba to correctly enter in the vehicle make. VBA will enter in the "Make" but the list box for the model won't appear.
I need VBA to enter in all the fields automatically and I need to figure out how VBA can correctly enter in the vehicle make and the webpage allows vba to enter in the model.
Here is the code:
I am using 2013.
I am open to suggestions
Thank you
Need support with a macro to populate a webpage. I'm new to VBA and can't seem to figure out how to solve this.
When complete, the macro should:
Open internet explorer
go to a specific web page
enter in a postal code
click on the next page
wait 10 seconds to load
enter in a year
enter in a vehicle make
enter in a vehicle model
etc.
The problem i'm having is that the "vehicle make" has a dropdown "list box selections: that affect the "vehicle model" and I can't get vba to correctly enter in the vehicle make. VBA will enter in the "Make" but the list box for the model won't appear.
I need VBA to enter in all the fields automatically and I need to figure out how VBA can correctly enter in the vehicle make and the webpage allows vba to enter in the model.
Here is the code:
Code:
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As InternetExplorer
Sub Kanetix()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "https://www.kanetix.ca"
Set MyBrowser = New InternetExplorer
MyBrowser.Silent = True
MyBrowser.navigate MyURL
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.POSTAL_CODE.Value = "l9a 2z3" 'places in postal code
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next 'goes to the next page
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
Do
DoEvents
Loop Until ie.readyState = 4
Application.Wait (Now + TimeValue("0:00:10")) 'wait till page loads
HTMLDoc.all.VehicleYear_1.Value = "2014"
HTMLDoc.all.VehicleMake_1.selectedIndex = "3"
HTMLDoc.all.VehicleModel_1.selectedIndex = "3"
HTMLDoc.all.Vehicle_purchase_month_1.Value = "November"
Application.Wait (Now + TimeValue("0:00:06"))
HTMLDoc.all.Leased_1.Value = "no"
HTMLDoc.all.Vehicle_purchase_year_1.Value = "2014"
MsgBox "done"
End Sub
I am using 2013.
I am open to suggestions
Thank you