+ Reply to Thread
Results 1 to 11 of 11

Send Screen Capture via Outlook

Hybrid 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

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

    Re: Send Screen Capture of Active Window via Outlook to a predefined E-Mail Adress

    Hello All,

    Does anyone have any idea for solution?

    Thanks for your support.

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

    Re: VBA: Send Screen Capture of Active Window via Outlook to a predefined E-Mail Adre

    I also have attached a simple sample file to make clear what i am telling.

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

    Re: VBA: Send Screen Capture of Active Window via Outlook to a predefined E-Mail Adre

    Dear All,

    Has nobody any idea about the solution?

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

    Re: VBA: Send Screen Capture of Active Window via Outlook to a predefined E-Mail Adre

    Dear All,

    Has nobody any idea about the solution?

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send Screen Capture via Outlook

    Hi huseyinkasirga
    Let me look at this for a bit. I've successfully done this
    take a screenshot of an active Excel window (it is a userform)
    and I've successfully been able to embed an image into the Outlook Email body. Let me see what I can do. I'll get back to you.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send Screen Capture via Outlook

    Hi huseyinkasirga
    What versions of Excel, Outlook and Word are you running? Your profile indicates 2003 but you attached an .xlsm file.

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

    Re: Send Screen Capture via Outlook

    Hello jaslake,

    Thank you very much for your attention and support. I am working with 2003 version Office. The file that I have uploaded was prepared in Office 2010, because I have prepared and uploaded that example from another computer. However I am working with 2003 to create a userform and also the users are using 2003.

    Thanks in advance
    Last edited by huseyinkasirga; 02-09-2012 at 03:42 PM.

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

    Re: Send Screen Capture via Outlook

    Just now I have updated the attachment with 2003 version and created a simple userform to make us able to try codes. It seems that problem is maybe paste code, because ScreenCapture code copies the image to clipboard, emailimage code is starting outlook with a new mail, but the image is not pasted
    Attached Files Attached Files
    Last edited by huseyinkasirga; 02-09-2012 at 03:45 PM.
    Best Regards,

    Kasirga

  10. #10
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Send Screen Capture via Outlook

    Hi Kasirga

    My research has indicated one cannot do a copy/paste into the Outlook Email Body. The code in the attached overcomes that and is attributed to Leith Ross and Ivan F Moala (http://www.xcelfiles.com/EmailImg.html). I've merely adapted it to my needs and to the requests of OP's. There are other ways to do this but I've not been successful implementing these other ways in pre-2007 Excel/Outlook.

    Please note...you'll need to set these references in VBA (or whatever version you have available) References.jpg

    Play with it...let me know of issues.
    Attached Files Attached Files

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

    Re: Send Screen Capture via Outlook

    Hello John,

    It really worked also for me. Thank you very much for your support

+ Reply to Thread

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