Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys Function

Status
Not open for further replies.

drewcp

Programmer
Jul 31, 2008
30
US
I tried writing a code that will send a series of keystrokes to an external application

i have been trying for a long time to do this and finally was able to get it to this point by using this article i found on MSDN


here is the code i wrote

Code:
Private Sub Command11_Click()
On Error GoTo Err_Command0_Click

    DoCmd.OpenForm "Sketch"
    
    My.Computer.Keyboard.SendKeys(^c ,wait)

    DoCmd.Close acForm, "Sketch"
    
    Dim stAppName As String
    
    stAppName = "W:\Sketch.exe"
    Call Shell(stAppName, 1)

    My.Computer.Keyboard.SendKeys(% ,wait)
    My.Computer.Keyboard.SendKeys({RIGHT})
    My.Computer.Keyboard.SendKeys({RETURN} ,wait)

    stAppName = "H:\set_click.exe"
    Call Shell (stAppName,1)

    My.Computer.Keyboard.SendKeys(^+{END})
    My.Computer.Keyboard.SendKeys(^v)
    My.Computer.Keyboard.SendKeys({TAB 6})
    My.Computer.Keyboard.SendKeys({RETURN} ,wait)
    My.Computer.Keyboard.SendKeys({RETURN} ,wait)

Exit_Command0_Click:
    Exit Sub

Err_Command0_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_Command0_Click
End Sub

obviously i didn't do something right because when it is in my code area, each My.Computer.Keyboard.SendKeys() command is in red and it won't run

does anyone know what i can do to fix this?
 
In VBA, SendKeys is a native instruction, so get rid of all the My.Computer.Keyboard. stuff and press the F1 key when the cursor is inside the SendKeys word in your code.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top