Hello,
I have an excel workbook with about 20 worksheets and need to save a range of sheets as individual PDFs files, each pdf's name the same as the respective worksheet name.
Appreciate some help with a VBA macro to do this.
I tried the following code but keep getting a Run time Error "5"; invalid procedure call or argument.
Option Explicit
Public Sub SaveWorkbookSheetsAsPDFs()
Dim WB As Workbook
Dim WS As Worksheet
Set WB = Workbooks.Open(Application.GetOpenFilename("Excel workbooks (*.xlsx), *.xlsx"))
For Each WS In WB.Worksheets
SaveSheetAsPDF WS
Next WS
WB.Close savechanges:=False
End Sub
Sub SaveSheetAsPDF(WS As Worksheet)
WS.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=WS.Parent.Path & Application.PathSeparator & WS.Name, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub
many thanks,
Sands
Bookmarks