search
LoginSignup
29
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

ExcelVBAでスクリーンショットを取る方法

コード(VBA)

'64bit版
Private Declare PtrSafe Sub keybd_event Lib "user32" ( _
    ByVal bVk As Byte, _
    ByVal bScan As Byte, _
    ByVal dwFlags As Long, _
    ByVal dwExtraInfo As Long _
        )

'32bit版
'Private Declare Sub keybd_event Lib "user32" ( _
    ByVal bVk As Byte, _
    ByVal bScan As Byte, _
    ByVal dwFlags As Long, _
    ByVal dwExtraInfo As Long _
        )

Public Sub 全体を撮る()
    keybd_event vbKeySnapshot, 0&, &H1, 0&
    keybd_event vbKeySnapshot, 0&, &H1 Or &H2, 0&
End Sub

Public Sub アクティブ画面を撮る()
    keybd_event &HA4, 0&, &H1, 0&
    keybd_event vbKeySnapshot, 0&, &H1, 0&
    keybd_event vbKeySnapshot, 0&, &H1 Or &H2, 0&
    keybd_event &HA4, 0&, &H1 Or &H2, 0&
End Sub

参考サイト

Excel VBA を学ぶなら moug モーグ | 即効テクニック | 画面をキャプチャする

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
29
Help us understand the problem. What are the problem?