+ Reply to Thread
Results 1 to 5 of 5

Macro Button to send Entire Workbook as PDF via email

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-25-2010
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2010
    Posts
    138

    Macro Button to send Entire Workbook as PDF via email

    Good Afternoon,

    As per the subject, I am looking for a Macro + Button to send the entire workbook as PDF via e-mail.

    I have 3 sheets - "DAY SHIFT" "NIGHT SHIFT" "PRODUCT LIST" - (Product List Is Hidden)

    I want to send the day & night shift to PDF and leave the product list out of it.

    Can anybody please assist me?

    Regards
    Ross

  2. #2
    Forum Contributor
    Join Date
    02-25-2010
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Macro Button to send Entire Workbook as PDF via email

    This is what I am currently using, But this only sends an .xlsx sheet.....


    Sub Mail_Workbook_1()
        
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
       
        With OutMail
            .To = ""
            .CC = ""
            .BCC = ""
            .Subject = "This is the Subject line"
            .Body = "Hello World!"
            .Attachments.Add ActiveWorkbook.FullName
            .Display
            
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub

  3. #3
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Macro Button to send Entire Workbook as PDF via email

    You´re welcomed.

    and regarding your next request, I´m sorry, I´m not familiar with that piece. I use two options to mail things one is the simple one you´ve had up there and second to mail pictures and stuff in the body of the mail, but either of those is similiar to this...

    anyways I suggest you to close this thread as solved and create another one since its not relevant anymore I believe (if my previous proposal is working as desired).

    Also you might wanna consider the add reputation button if you liked my insights

    Best regards

    Soul

  4. #4
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague, Czech rep.
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    138

    Re: Macro Button to send Entire Workbook as PDF via email

    Hi Rosco88,

    here is the macro to save the sheets as PDF file:

        Sheets(Array("Day Shift", "Night shift")).Select
        Sheets("Day Shift").Activate
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
            "Enter the path and file name", Quality:=xlQualityStandard, _
            IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
            False
    just as stated enter proper filepath

    and regarding the sending part you have it right just instead of active workbook, give it a path to the file you wanna send with the double quotes

    best regards

    Soul

  5. #5
    Forum Contributor
    Join Date
    02-25-2010
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2010
    Posts
    138

    Re: Macro Button to send Entire Workbook as PDF via email

    Thanks Soul!

    I am also looking to add a CC to the below code.... Can anyone assist?

    Sub RDB_Workbook_To_PDF_And_Create_Mail()
        Dim FileName As String
    
        'Call the function with the correct arguments
        FileName = RDB_Create_PDF(ActiveWorkbook, "", True, False)
    
        'For a fixed file name and overwrite it each time you run the macro use
        'RDB_Create_PDF(ActiveWorkbook, "C:\Users\Ron\Test\YourPdfFile.pdf", True, False)
    
        If FileName <> "" Then
            RDB_Mail_PDF_Outlook FileName, "ron@debruin.nl", "Daily Production Sheet", _
                                 "" _
                               & vbNewLine & vbNewLine & "Best Regards", False
        Else
            MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
                   "Microsoft Add-in is not installed" & vbNewLine & _
                   "You Canceled the GetSaveAsFilename dialog" & vbNewLine & _
                   "The path to Save the file in arg 2 is not correct" & vbNewLine & _
                   "You didn't want to overwrite the existing PDF if it exist"
        End If
    End Sub
    Thanks
    Ross

+ 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. command button VBA to send automated email not workbook or worksheet
    By lpratt in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-08-2012, 11:13 PM
  2. 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
  3. Button - Send email
    By Wiets in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2008, 09:04 PM
  4. command button to send email
    By artromanov in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2007, 09:02 PM
  5. [SOLVED] send email from button
    By andreww in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-20-2005, 11:05 AM

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