Results 1 to 11 of 11

Send Screen Capture via Outlook

Threaded View

  1. #1
    Registered User
    Join Date
    02-05-2012
    Location
    İstanbul
    MS-Off Ver
    Microsoft Office 2003
    Posts
    10

    Exclamation Send Screen Capture via Outlook

    Dear All

    I aim to take a screenshot of an active Excel window (it is a userform) and send it in the body of a Outlook E-Mail as image with clicking on a commandbutton on userform. I found some codes; however I think I have mistake combining two codes together. Here are two codes I am working on. First one is "ScreenCapture" to copy the active window into clipboard and second one is "emailimage" to paste clipboard to outlook mail. If I run them seperately with two buttons (see attachment: click first ScreenCapture and then emailimage), they do exactly what I want. However I cannot combine them to run just with 1 click (I have used "Call" code, but ScreenCapture is not seems to work properly, it takes capture of outlook mail: see attachment and click RunBoth button). How can I combine them together or run them properly with just 1 click on userform?

    Kitap1.xlsm

    Thanks in advance

    CODE-1: ScreenCapture (to take screenshot of active window)
    '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, 1, 0, 0
        keybd_event VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0
        keybd_event VK_MENU, 0, KEYEVENTF_KEYUP, 0
    End Sub
    CODE-2: emailimage (to paste clipboard to a new mail and send/display it)
    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 = "[email protected]"
            .Subject = "Subject line"
            .Display
        
            Application.SendKeys "(^v)"
            
        End With
    On Error GoTo 0
    
    OutApp.Session.Logoff
    Set OutMail = Nothing
    Set OutApp = Nothing
    
    End Sub
    CODE-3: Runboth (to run two different macro with 1 click)
    Sub Runboth()
    Call ScreenCapture
    Call emailimage
    End Sub
    Last edited by huseyinkasirga; 02-10-2012 at 07:14 AM. Reason: Attached File

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1