Print screen using VBA in SAP

SAPVBA

If you are using SendKeys then avoid using it. I had used it in the past project and it seems to be inconsistent and error-prone.

You can use the below snippet at the top of the module and call it wherever required.

Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _bScan As Byte,
 ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 1, 0, 0
 End Sub
raja
Published on 27-Dec-2017 13:19:29
Advertisements