How to save multiple excel sheets as separate pdf files in different names?

RyanWi

New Member
Joined
May 15, 2013
Messages
22
Hi,

I have 1 workbook with 12 excel sheets.
Each contains an invoice, and i need to export all sheets to different PDF files and under different names.

Eg.
Sheet 1 - > Invoice 01 ---> Invoice01.pdf
Sheet 2 - > Invoice 02 ---> Invoice02.pdf
Sheet 3 - > Invoice 03 ---> Invoice03.pdf
Sheet 4 - > Invoice 04 ---> Invoice04.pdf
.....etc

Thanks.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
paste code into a module, then run : ExportAllPdfs

Code:
Sub ExportAllPdfs()
Dim ws As Worksheet
Dim vDir, vFile, vName

vDir = Environ$("USERPROFILE") & "\Documents\"

For Each ws In Sheets
  ws.Activate

vName = replace(ws.Name, "Sheet","Invoice")
  vFile = vDir & vName & ".pdf"
 
   ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=vFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Next
Set ws = Nothing
End Sub
 
Last edited:
Upvote 0
Solution
paste code into a module, then run : ExportAllPdfs

Code:
Sub ExportAllPdfs()
Dim ws As Worksheet
Dim vDir, vFile, vName

vDir = Environ$("USERPROFILE") & "\Documents\"

For Each ws In Sheets
  ws.Activate

vName = replace(ws.Name, "Sheet","Invoice")
  vFile = vDir & vName & ".pdf"
 
   ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=vFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Next
Set ws = Nothing
End Sub
Hi,

Super thanks!
It works.

Only thing i want to change the location to
E:\EXCEL\Data\MonthName2023\
 
Upvote 0

Forum statistics

Threads
1,215,135
Messages
6,123,239
Members
449,093
Latest member
Vincent Khandagale

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