+ Reply to Thread
Results 1 to 4 of 4

Macro to create an email, attach current workbook and also paste a range from sheet

Hybrid View

StormFusion Macro to create an email,... 06-10-2019, 05:38 AM
davesexcel Re: Macro to create an email,... 06-10-2019, 08:55 AM
Logit Re: Macro to create an email,... 06-10-2019, 10:47 AM
StormFusion Re: Macro to create an email,... 06-12-2019, 08:32 AM
  1. #1
    Registered User
    Join Date
    03-27-2019
    Location
    Portsmouth
    MS-Off Ver
    Microsoft Office 2021
    Posts
    44

    Macro to create an email, attach current workbook and also paste a range from sheet

    Hi,

    How do I use VBA to create an email, attach a temporary version of the active workbook and then paste a range from a sheet within the workbook as an image?

    Thanks in advance.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,529

    Re: Macro to create an email, attach current workbook and also paste a range from sheet

    Type "Email from excel" in the search box

  3. #3
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,485

    Re: Macro to create an email, attach current workbook and also paste a range from sheet

    .
    https://www.rondebruin.nl/win/s1/outlook/mail.htm

    Create what you are able to ... then post your workbook with your macro code and specify your problem/s.

  4. #4
    Registered User
    Join Date
    03-27-2019
    Location
    Portsmouth
    MS-Off Ver
    Microsoft Office 2021
    Posts
    44

    Re: Macro to create an email, attach current workbook and also paste a range from sheet

    Hi,

    This is as far as I got, it will create an email, save the workbook as temp and attach to the email, now I need it to also paste an image of the range as defined...

    Sub Email_CurrentWorkBook2()
        Dim OlApp As Object
        Dim NewMail As Object
        Dim TempFilePath As String
        Dim FileExt As String
        Dim TempFileName As String
        Dim FileFullPath As String
        Dim MyWb As Workbook
        Dim wordDoc As Word.Document
    
        Set MyWb = ThisWorkbook
    
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
        End With
    
        TempFilePath = Environ$("temp") & "\"
    
        FileExt = "." & LCase(Right(MyWb.Name, Len(MyWb.Name) - InStrRev(MyWb.Name, ".", , 1)))
    
        TempFileName = MyWb.Name & " - " & Format(Now, "DD.MM.YYYY")
    
        FileFullPath = TempFilePath & TempFileName & FileExt
    
        MyWb.SaveCopyAs FileFullPath
    
        sheet1.Range("A1:Z100").Copy
    
    
        Set OlApp = CreateObject("Outlook.Application")
        Set NewMail = OlApp.CreateItem(0)
    
        On Error Resume Next
        With NewMail
            .To = "a@b.com"
            .Subject = "DASH"
            .Body = ""
            .Attachments.Add FileFullPath '--- full path of the temp file where it is saved
            .Send   'or use .Display to show you the email before sending it.
        End With
            
        Set wordDoc = OlApp.GetInspector.WordEditor
        'To paste as picture
        wordDoc.Range.PasteAndFormat wdChartPicture
    
        On Error GoTo 0
        Kill FileFullPath
        Set NewMail = Nothing
        Set OlApp = Nothing
        With Application
            .ScreenUpdating = True
            .EnableEvents = True
        End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create macro to copy current sheet to new folder and with new name of workbook
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-29-2016, 02:21 PM
  2. Macro to create emai and attach picture for every unique email address.
    By melody10 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-12-2015, 11:45 AM
  3. Macro to attach range to email in new sheet but not send?
    By Serafin54 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-22-2014, 01:07 PM
  4. Attach just one sheet of a workbook to an email
    By papasmurfuo9 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2014, 10:17 AM
  5. [SOLVED] Macro to create a pdf and attach to an email (Outlook)
    By jsedore in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-01-2013, 03:16 PM
  6. Macro to attach workbook to Outlook email but NOT send
    By kbwilsdon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-11-2009, 06:57 AM
  7. How can i attach active workbook to email- please see the macro
    By stric in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2005, 06:05 PM

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