Multiple Sheets to Individual PDFs

jessi8188

New Member
Joined
Aug 26, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi, I need to print multiple sheets from the same workbook to individual PDFs.

I need it to create a folder on the desktop if possible using cell A1 from the Master sheet which contains the date of payment.
For every sheet in the workbook I want it to save using Name of Sheet & Master!A1
I then want it to activate the Master sheet.

Everything I have tried so far just keeps giving me errors.

Sub ExportToPDFs()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Select
nm = ws.Name
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Users\xo-je\Documents\Fins\" & nm & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next ws
Sheets("master").Activate
End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi & welcome to MrExcel.
How about
VBA Code:
Sub jessi()
   Dim Dte As String, Pth As String
   Dim Ws As Worksheet
   
   Dte = Format(Sheets("Master").Range("A1").Value, "dd_mm_yyyy")
   Pth = Environ("userprofile") & "\Desktop\" & Dte & "\"
   If Dir(Pth, vbDirectory) = "" Then
      MkDir Pth
   End If
   For Each Ws In Worksheets
      If LCase(Ws.Name) <> "master" Then
         Ws.ExportAsFixedFormat xlTypePDF, Pth & Ws.Name & " " & Dte & ".pdf", xlQualityStandard, True, False, , , False
      End If
   Next Ws
   Sheets("Master").Activate
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
How about
VBA Code:
Sub jessi()
   Dim Dte As String, Pth As String
   Dim Ws As Worksheet
  
   Dte = Format(Sheets("Master").Range("A1").Value, "dd_mm_yyyy")
   Pth = Environ("userprofile") & "\Desktop\" & Dte & "\"
   If Dir(Pth, vbDirectory) = "" Then
      MkDir Pth
   End If
   For Each Ws In Worksheets
      If LCase(Ws.Name) <> "master" Then
         Ws.ExportAsFixedFormat xlTypePDF, Pth & Ws.Name & " " & Dte & ".pdf", xlQualityStandard, True, False, , , False
      End If
   Next Ws
   Sheets("Master").Activate
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,598
Messages
6,120,441
Members
448,966
Latest member
DannyC96

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