VBA to save multiple sheets as 1 PDF with cell value as file name

hsmith15

New Member
Joined
Jan 19, 2018
Messages
8
I need to create 1 PDF of 5 sheets (Sheet2 - Sheet7)

File name needs to be value of cell "O1" in "Sheet2"

File Path: "C:\Users\SP3\Dropbox (1 Stone Solutions)\1 Stone Solutions Team Folder\ Corporate\Hayden Smith\Sales Reporting\Weekly Sales Reports"

I will be running the macro out of Sheet2

Please HELP!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Code:
Sub save_sheets()

const myPaht = "C:\Users\SP3\Dropbox (1 Stone Solutions)\1 Stone Solutions Team Folder\  Corporate\Hayden Smith\Sales Reporting\Weekly Sales Reports\"

ThisWorkbook.Sheets(Array(ThisWorkbook.Sheets(2).Name, ThisWorkbook.Sheets(3).Name, _
ThisWorkbook.Sheets(4).Name, ThisWorkbook.Sheets(5).Name, ThisWorkbook.Sheets(6).Name, ThisWorkbook.Sheets(7).Name)).Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=myPath & Sheets(2).Range("O1") & ".pdf", _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=True




End Sub
 
Upvote 0
Thank you, that does exactly what I need it to.

What would the code be to then send an email to someone with the newly saved pdf file attached with a body of text in the email as well?
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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