Need to send keystrokes to windows API
I need to automate the download of a spreadsheet from an internet site. The following VBA code written in Excel, accesses the site and fetches a dialog box (API form?) with 2 buttons asking to Save (desired) or Cancel. The manual keystrokes of {TAB}{TAB}{ENTER} saves the file, however I have not been successful in automating these. Here is the code - can anyone suggest how to proceed?
Sub DownloadInv()
Dim obIE As Object
Dim vURL As String
vURL = "http://www.cmb-satellite.com/dloads/CMB.DBF"
Set obIE = CreateObject("InternetExplorer.Application")
obIE.Visible = True
obIE.navigate (vURL)
' The code above fetches the dialog box - the following code does not work.
' There is no error message but the keystrkes never get to the dialog box
' even thought it has focus.
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
End Sub
Please help
Stosh
I need to automate the download of a spreadsheet from an internet site. The following VBA code written in Excel, accesses the site and fetches a dialog box (API form?) with 2 buttons asking to Save (desired) or Cancel. The manual keystrokes of {TAB}{TAB}{ENTER} saves the file, however I have not been successful in automating these. Here is the code - can anyone suggest how to proceed?
Sub DownloadInv()
Dim obIE As Object
Dim vURL As String
vURL = "http://www.cmb-satellite.com/dloads/CMB.DBF"
Set obIE = CreateObject("InternetExplorer.Application")
obIE.Visible = True
obIE.navigate (vURL)
' The code above fetches the dialog box - the following code does not work.
' There is no error message but the keystrkes never get to the dialog box
' even thought it has focus.
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
End Sub
Please help
Stosh
Last edited: