vba 如何发送 ALT TAB 键?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18666468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:34:53  来源:igfitidea点击:

How do I SendKeys an ALT TAB?

vbaexcel-vbaexcel

提问by Michaeljwjr

Application.SendKeys "{PGDN}", True

Application.SendKeys "{PGDN}", True

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

工作得很好,但是 Application.SendKeys "{%TAB}", True 和 Application.SendKeys "%{TAB}", True 什么都不做。

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

如何使用 sendkeys 执行 alt-tab 来切换窗口?

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

回答by Gary's Student

Use this:

用这个:

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

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

必须在 Excel 而不是 VBE 中运行