Dec 14 2020 12:03 PM
HI Everyone,
I have been running the macro below for a few months now without any problems:
Today when I tried to run the macro I received this error message - Run-time error 'S': Invalid procedure call or argument.
The error occurs at the red text.
Macro:
Sub LoopSheetsSaveAsPDF()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=ThisWorkbook.Path & "/" & ws.Name & ".pdf"
Next
End Sub
Dec 14 2020 01:08 PM
Dec 14 2020 05:39 PM
@Jihad Al-Jarady Thank you.
There were no empty worksheets, however, there were hidden worksheets. I unhide these and the macro now works as expected.
Your suggestion of removing empty worksheets led me in the right direction.