Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I SendKeys an ALT TAB?

Tags:

excel

vba

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
like image 370
Michaeljwjr Avatar asked Sep 06 '13 20:09

Michaeljwjr


1 Answers

Use this:

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

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

like image 121
Gary's Student Avatar answered Nov 15 '22 10:11

Gary's Student