+ Reply to Thread
Results 1 to 16 of 16

Sending screenshot via outlook using excel code

Hybrid View

ge0rge Sending screenshot via... 10-23-2008, 09:53 AM
arthurbr Is it an xl screenshot? 10-23-2008, 09:57 AM
ge0rge It would be of another... 10-23-2008, 10:58 AM
Leith Ross Hello ge0rge, It is... 10-23-2008, 11:16 AM
ge0rge That would be great. In the... 10-23-2008, 11:28 AM
skultety Sending screenshot via... 12-06-2010, 10:31 AM
huseyinkasirga Re: Sending screenshot via... 02-06-2012, 06:16 PM
huseyinkasirga Re: Sending screenshot via... 02-07-2012, 04:43 AM
Domski Re: Sending screenshot via... 02-07-2012, 05:23 AM
  1. #1
    Forum Contributor
    Join Date
    11-09-2007
    Location
    USA
    MS-Off Ver
    2003
    Posts
    141

    Sending screenshot via outlook using excel code

    I am in need of some way to capture a screen shot of a program on screen and send it to a specified email address at a certain time of the day. I would not think its impossible, could it be done using vba code?

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    I am in need of some way to capture a screen shot of a program on screen
    Is it an xl screenshot?

  3. #3
    Forum Contributor
    Join Date
    11-09-2007
    Location
    USA
    MS-Off Ver
    2003
    Posts
    141
    It would be of another program open on the desktop. I am also thinking it may be easier to have it save the screenshot to a folder instead of emailing it.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ge0rge,

    It is doable. I will be out of my office for a while, but will dig the code up when I get back.

    Sincerely,
    Leith Ross

  5. #5
    Forum Contributor
    Join Date
    11-09-2007
    Location
    USA
    MS-Off Ver
    2003
    Posts
    141
    That would be great. In the meantime I am going to give it a go.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello ge0rge,

    Capturing the screen is the easy part. I am having problems with embedding a picture in Outlook. Not sure if is my email setup or a problem with Outlook. I'll keep you updated.

    Macro Code to Capture the Screen
    '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
    Sincerely,
    Leith Ross

  7. #7
    Registered User
    Join Date
    12-03-2010
    Location
    Amsterdam
    MS-Off Ver
    Excel 2003
    Posts
    5

    Talking Sending screenshot via outlook using excel code

    (deleted)...

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

    Re: Sending screenshot via outlook using excel code

    Hello Leith,

    I found you here too May you remember my problem from another forum. 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 (click first then second), they do 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 ). How can I combine them together or run them properly with just 1 click?

    1.Code: "Screencapture"
    '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
    2.Code: "emailimage" to paste clipboard into email body
    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
    3. Runboth:
    Sub Runboth()
    Call ScreenCapture
    Call emailimage
    End Sub
    Last edited by huseyinkasirga; 02-06-2012 at 06:19 PM.

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

    Re: Sending screenshot via outlook using excel code

    Dear All,

    Can anybody help me about the problem mentioned above?

    Thanks in advance.

  10. #10
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Sending screenshot via outlook using excel code

    Please take a moment to read the forum rules.

    2. Don't post a question in the thread of another member -- start your own. If you feel it's particularly relevant, provide a link to the other thread.
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ 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