I am trying to check several vins entered into excel in a chrome browser, this code will open the browser and enter them in but it wont hit enter to click the button. Not sure what I am doing wrong but i have tried several variations and cant seem to come up with anything.
Sorry if my formatting is terrible this is my first time posting here.
chromePath = """C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"""
StartRow = 2
EndRow = InputBox("Please enter how many vins to check!")
RowIndex = 2
EndRow = 1 + EndRow
For i = StartRow To EndRow
Vin = Sheets("VinCheck").Cells(i, "A")
browser = Shell(chromePath & " -url https://www.autoreturn.com/indianapolis-in/find-vehicle/ ")
Application.Wait Now + 0.00003
Application.SendKeys "{Tab}", True
Application.SendKeys "{Tab}", True
Application.SendKeys "{Tab}", True
Application.SendKeys "{Tab}", True
Application.SendKeys Vin, True
Application.SendKeys "{~}", True
Application.SendKeys "{Tab}", True
Application.Wait Now + 0.00003
Msg = "Was Vehicle Found?" & vbCrLf & "Click Yes to move on to the next Vin"
MsgBox Msg, vbYesNo, "Advanced Excel Training"
If Response = vnYes Then
Sheets("VinCheck").Cells(i, "B").Value = "Found"
Else
Sheets("VinCheck").Cells(i, "B").Value = "Vehicle Not Found"
End If
Next i
End Sub
I would give selenium basic wrapper for vba a try if you are allowed to install. After installation you add a reference to selenium type library via vbe > tool > references. You need the latest chrome install and chromedriver and the chromedriver.exe should be in the same folder as the selenium executables.
Then the syntax for your task is nice and descriptive. I haven't added a loop over vins but the essential elements for the search are shown. I provide a sub to write out results to a worksheet.
I'd like to be able to remove the explicit wait after SendKeys but there doesn't appear to be any page event/change I can monitor to determine when to click the button and have the sent vin included. A 1 sec wait appears consistently to be sufficient. You could explore reducing this depending on how many searches you are performing.