问题
I am trying to send a page down keypress using VBA but nothing I have tried has worked.
I have tried;
Myscreen.SendKeys "{PGDN}"
Myscreen.SendKeys ("{PGDN}")
Myscreen.SendKeys ("<PGDN>")
Myscreen.SendKeys "{PAGE DOWN}"
Myscreen.SendKeys ("{PAGE DOWN}")
Myscreen.SendKeys ("<PAGE DOWN>")
Myscreen.SendKeys "{PAGE DN}"
Myscreen.SendKeys ("{PAGE DN}")
Myscreen.SendKeys ("<PAGE DN>")
Myscreen.SendKeys "{Down}"
Myscreen.SendKeys ("{Down}")
Myscreen.SendKeys ("<Down>") - this was the only that did anything, but it moved the cursor down a line instead of paging down
I got delete to work using Myscreen.Sendkeys ("") but it doesn't work for page down for some reason.
Does any one have any ideas?
回答1:
The correct Syntax for {Page Down} should be
Option Explicit
Sub sndkey()
'// to send multiple times try "{PGDN 5}"
Application.SendKeys "{PGDN}"
End Sub
look at MSDN & SendKeys Class
Edit
okay I have tested it works
Option Explicit
Sub sndkey()
Dim Myscreen As Object
Set Myscreen = Sys.Screen
'// to send multiple times try "{PGDN 5}"
Myscreen.SendKeys "{PGDN 6}"
End Sub
来源:https://stackoverflow.com/questions/31460447/sendkeys-page-down-not-working