Print Screen Using VBA in SAP



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
Updated on: 2019-12-16T07:51:47+05:30

807 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements