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
How do I SendKeys an ALT TAB?
提问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 中运行。