Hoping someone can assist. I want to select all worksheets within my workbook and save worksheets into 1 PDF file. I have found some VBA code online (see below) which does this, but unfortunately the PDF file does not have the Page Setups I had previously applied within each worksheet. Each worksheet has Page Setup to have orientation of Landscape and FitToPagesWide / FitToPagesTall to = 1.
Any idea why PageSetups don't come across when saving to PDF ? Any help is greatly appreciated.
Any idea why PageSetups don't come across when saving to PDF ? Any help is greatly appreciated.
Code:
Private Sub Save_File_to_PDF()
'---- Create a dynamic array which will house all the worksheet names in the workbook to be saved to PDF file
Dim myArray() As Variant
Dim i As Integer
For i = 1 To Sheets.Count
ReDim Preserve myArray(i - 1)
myArray(i - 1) = i
Next i
'--- select all the worksheets within the array so can save to 1 PDF file
Sheets(myArray).Select '---- this command seems to reset the PageSetting back to the defaults for some reason???:confused:
'--- save file ---
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:="C:\Assets.PDF" , _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=True, _
OpenAfterPublish:=True
End Sub