I am trying to screen capture and send the image via Email. However, sometimes it works, and sometimes the screen capture ends up in the Excel WorkSheet.. Any idea one what I can do to make this more consistent?
Code
Private Sub auto_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Call PrintTheScreen
Application.Wait (Now + TimeValue("0:00:2"))
strbody = "screen shot of your screen"
On Error Resume Next
With OutMail
.to = "[email protected]"
.cc = ""
.BCC = ""
.Subject = "Updated Unit Training Tracker"
.Body = strbody
.Display
SendKeys "^v", True
DoEvents
Application.Wait (Now + TimeValue("0:00:2"))
.send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Sub PrintTheScreen()
Application.SendKeys "(%{1068})"
DoEvents
End Sub
Display More