I have set up a macro to print to PDF all sheets within a workbook (thanks to some input from this forum). It works on some workbooks, but tried running the macro today, and I got a message box that called the activesheet "working ", but not by the actual worksheet name. When I clicked "ok" to shut down the msgbox, I got a Run-time error '5', Invalid procedure call or argument.. Here is the code:
Sub SavePDFAllWorkSheet()
'
' SavePDFAllWorkSheet Macro
'
Dim APath As String
Dim s As Long
Dim ASName As String
APath = ActiveWorkbook.Path & "\"
MsgBox APath
For s = 1 To Sheets.Count
Sheets(s).Activate
ASName = ActiveSheet.Name
' this is where it said "Working" in the MsgBox
MsgBox ASName
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
APath & ASName, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next
End Sub
Bookmarks