I am looking to speed up the exchange from vba to IE. The sendkeys works, but I was curious if there were a better way to do this?
The site that it routes to is a form, but there is no submit button. The only way to pull the data is to tab to the next box or click somewhere on the screen. I was hoping, however, to have all of this automated through VBA.
Thoughts?
Public Declare Function SetForegroundWindow Lib "user32" (ByVal HWND As Long) As Long
Function FillInternetForm()
Dim HWNDSrc As Long
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
'create new instance of IE. use reference to return current open IE if
'you want to use open IE window. Easiest way I know of is via title bar.
HWNDSrc = ie.HWND
ie.Navigate "http://helppointinfo.farmersinsurance.com/OCR/Labor_Rates/laborrates.asp"
'go to web page listed inside quotes
ie.Visible = True
While ie.Busy
DoEvents 'wait until IE is done loading page.
Wend
ie.Document.getElementById("DirectZip").Value = Sheets("NAT").Range("C2").Value
SetForegroundWindow HWNDSrc
Application.SendKeys "{TAB 11}", True
DoEvents
Application.SendKeys "{NUMLOCK}", True
End Function
Public Sub RunRates()
Call FillInternetForm
End Sub