Need to send keystrokes to Internet Explorer?

Joined
Sep 10, 2008
Messages
2
Reaction score
0
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
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top