VBA: Exporting all Workbook Sheets to one PDF - none of the solutions online work!

MrStephen

New Member
Joined
Mar 9, 2018
Messages
1
Hi all,

I'm having trouble with the task of exporting all the worksheets in a workbook into a single PDF using VBA. I'm working on Excel 2011 for Mac.

I've come across several suggestions on the internet, including here, and none of them result in a single PDF file containing the worksheet contents.

Code:
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\Sales.pdf", _
        openafterpublish:=False, ignoreprintareas:=False
Results in one PDF file per worksheet, named Sales + sheet name + pdf

Code:
    Sheets(Array("Bradford", "Kettering")).Select
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\Sales.pdf", _
        openafterpublish:=False, ignoreprintareas:=False
Results in only the "Kettering" spreadsheet being exported to Sales.pdf

Code:
    Sheets(Array("Bradford", "Kettering")).Select
   ActiveWindow.SelectedSheets.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\Sales.pdf", _
        openafterpublish:=False, ignoreprintareas:=False
Results in a compiler error as ExportAsFixedFormat is not a method of SelectedSheets.

Code:
   ActiveWorkbook.Sheets.Select
  Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\Sales.pdf", _
        openafterpublish:=False, ignoreprintareas:=False
Results in only the last Worksheet being exported to Sales.pdf

I'm really baffled at this point. Is there any process that actually works and results in one PDF containing all the Worksheets in my Workbook?

Many thanks!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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