none
Copy from Excel and paste on Outlook as image - VBA RRS feed

  • Question

  • Hello,

    I need to copy some information from range "x" and paste it in a new message on Outlook, but I need to paste as image.
    I did until opening a new message on Outlook, but I don't know how to paste the range copied as image.

    Can someone help me, please?

    I tried to insert on "theMailItem.body = body" something like: ActiveSheet.PasteAsImage but it didn't work.

        Sub email()
    
    ' copy and create a new email
    
        Range("B2:E21").Select
        Selection.Copy
    
     Dim theApp, theMailItem, MessageBody, subject
        
         'create a new Outlook Application Object,
         'create a new Mail Item
         Set mail = CreateObject("Outlook.Application")
         Set theMailItem = mail.CreateItem(olMailItem)
         theMailItem.Display
          
         'add recipients to MailItem
         theMailItem.subject = "Pre Alert"
         theMailItem.body = body
    End Sub
    

    Thank you!

    Best Regards,

    Caio

    Tuesday, October 31, 2017 3:33 PM

All replies

  • Hi Caio,

    You could use CopyPicture to copy the range as picture. The mail body is stored in WordEditor of the mail's inspector. You could try to access the WordEditor and then paste the picture to the body.

    Here is the example.

         Range("B2:E21").Select
         Selection.CopyPicture xlScreen, xlPicture
         'create a new Outlook Application Object,
         'create a new Mail Item
         Set mail = CreateObject("Outlook.Application")
         Set theMailItem = mail.CreateItem(olMailItem)
         theMailItem.Display
         'add recipients to MailItem
         theMailItem.Subject = "Pre Alert"
         Set ins = theMailItem.GetInspector
         'need add reference to Microsoft Word Object Library
         Dim doc As Word.Document
         Set doc = ins.WordEditor
         doc.Select
         doc.Application.Selection.Paste

    Best Regards,

    Terry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 1, 2017 5:06 AM