Send file as PDF through email

skf786

Board Regular
Joined
Sep 26, 2010
Messages
156
Hi,

my file has 4 sheets 1,2,3,4. i am looking for a macro to convert all for sheets into one pdf (same sequence 1,2,3,4). file name shall be XYZ-dd-mm-yyyy and it shall be attached to a new email through outlook and email shall remain open for user to input email address. Email subject shall be "Breakeven Analysis" and Text in body shall contain "abc"

Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this macro.
VBA Code:
Public Sub Create_PDF_and_Email()

    Dim PDFFileName As String
    Dim OutApp As Object
    Dim OutMail As Object
    
    With ActiveWorkbook
        PDFFileName = .Path & "\XYZ-" & Format(Date, "dd-mm-yyyy") & ".pdf"
        .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFileName, _
            Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
    End With
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .Subject = "Breakeven Analysis"
        .Body = "abc"
        .Attachments.Add PDFFileName
        .Display
    End With
    On Error GoTo 0
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,581
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top