【发布时间】:2015-02-15 20:26:23
【问题描述】:
此代码通过调用sub PrintScreen获取要粘贴的数字屏幕截图并将其粘贴到power point幻灯片中,然后需要5秒才能捕获活动窗口的屏幕。虽然我希望每当我按下“F7 或 F3 等”之类的特定键时,它都应该打印屏幕而不是等待 5 秒。我只想按下键,它会调用 sub 在其中我指定打印和粘贴以及其他功能。
Sub Screen_Capture_VBA()
Dim Sec4 As Date
MsgBox "Note: Three seconds after you click OK " & _
"the active window will be copied to the clipboard."
Sec4 = DateAdd("s", 4, Now)
myValue = InputBox("Give me no of screen shots you want to capture")
For I = 1 To myValue
PrintScreen
Next I
End Sub
这是我的打印屏幕子。
Sub PrintScreen()
Sleep 5000
keybd_event VK_MENU, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, 0, 0
keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
ActivePresentation.Slides.Add 1, ppLayoutBlank
ActivePresentation.Slides(1).Shapes.Paste
End Sub
【问题讨论】:
标签: vba keyboard-shortcuts powerpoint