jamieleeuk
Board Regular
- Joined
- Feb 9, 2009
- Messages
- 99
Is it possible to send a screenshot of a userform via an email to a specific email address once a button has been pressed on said userform?
'Written: October 23, 2008
'Author: Leith Ross
'Summary: Capture the screen image as a picture. VBA SendKeys won't do this function.
' It can be done using the WIndows API. The image is automatically transfered
' to the clipboard.
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 ScreenCapture()
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
End Sub
Sub emailimage()
Dim OutApp As Object
Dim OutMail As Object
'Shift-Print Screen
Application.SendKeys "(%{1068})"
On Error Resume Next
'Prepare the email
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "youremail@test.com"
.Subject = "Subject line"
.Display
Application.SendKeys "(^v)"
End With
On Error GoTo 0
OutApp.Session.Logoff
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sub Runboth()
Call ScreenCapture
Call emailimage
End Sub