Michaeljwjr
Michaeljwjr

Reputation: 423

How do I SendKeys an ALT TAB?

Application.SendKeys "{PGDN}", True

Works just fine, however Application.SendKeys "{%TAB}", True and Application.SendKeys "%{TAB}", True do nothing.

How do I execute an alt-tab with sendkeys to switch windows?

Here is the code:

Application.SendKeys "{PGDN}", True
Application.SendKeys "{PGDN}", True
xreply = MsgBox("Is this page for women? Record:" & i, vbYesNo, "Gender Checker")   
If xreply = vbYes Then
ActiveSheet.Range("C" & i).Value = vbYes
End If

Upvotes: 5

Views: 65670

Answers (1)

Gary's Student
Gary's Student

Reputation: 96753

Use this:

Sub ReturnToWindows()
    Application.SendKeys ("%{TAB}")
    DoEvents
End Sub

Must be run while you are in Excel rather than the VBE.

Upvotes: 6

Related Questions