Macro: Merge Multiple PDF and attach to E-Mail

ReaSCH

New Member
Joined
Jun 25, 2013
Messages
5
Dear all,

I found a great macro that prints a PDF and attaches it to e-mail - it work perfectly. However, I need to extend it, in order to first merge 9 different worksheets and then attach them to e-mail in one single PDF file.

Here comes the macro:

Code:
Sub SendPDF()
' Create PDF of active sheet and send as attachment.
'
    Dim strPath As String, strFName As String
    Dim OutApp As Object, OutMail As Object
   
     'Create PDF of active sheet only
    strPath = Environ$("temp") & "\" 'Or any other path, but include trailing "\"
   
    strFName = ActiveWorkbook.Name
    strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & ActiveSheet.Name & " " & Format(Now(), "mm.dd.yy hh.mm") & ".pdf"
   
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        strPath & strFName, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
       
     'Set up outlook
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

     'Create message
    On Error Resume Next
    With OutMail
        .to = "**e-mail address**" 'Insert required address here ########
        .CC = ""
        .BCC = ""
        .Subject = "Insert Subject Text Here"
        .Body = "Insert Body Text Here." & vbCr & "Best regards, etc." & vbCr
        .Attachments.Add strPath & strFName
        .Display   'Use only during debugging ##############################
        '.Send      'Uncomment to send e-mail ##############################
    End With

     'Delete any temp files created
    Kill strPath & strFName
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Could someone help me merging the "merge multiple worksheets in one PDF" code with the above one.

I highly appreciate your help.
Cheers,
Rea
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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