'How to fix code to save all worksheets as one PDF from the open workbook? VBA. It only prints the active worksheet right now for some reason.
Sub abc()
For i = 1 To Workbook.Worksheets.Count
With ActiveSheet.PageSetup
.CenterHeader = "Sample Excel File Saved As PDF"
.Orientation = xlPortrait
.PrintArea = "$B$5:$F$105"
.PrintTitleRows = ActiveSheet.Rows(5).Address
.Zoom = False
.FitToPagesTall = False
.FitToPagesWide = 1
End With
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="Sample Excel File Saved As PDF 2", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=5, _
OpenAfterPublish:=True
ActiveSheet.Next.Activate
Next i
End Sub