Hi folks, I need to print Mac Excel sheet to PDF quite often, here are the VBA code used to be working fine with my Office 2011, but it does’t work in Office 2016/2019, the macro is to print sheet to a fixed location, with file name format Invoice+sheet tab name, when I run the macro, it will highlight “PublishiOption:=, and says “Compile error: Name argument not found”, can anyone please tell me how to rectify it? thank you in advance
Sub SaveInvoice()
‘ SavePDF Macro
‘ Save sheet to PDF
‘
‘ Keyboard Shortcut: Option+Cmd+e
‘
ActiveSheet.Copy
Range(“A1:J60”).Select
ActiveWorkbook.SaveAs FileName:= _
“MBP2018:Users:Jackcai:Dropbox:Temp PDF:Invoice.pdf”, FileFormat:=xlPDF, _
PublishOption:=xlSheet
ActiveWorkbook.Close (False)
‘
End Sub
Have you tried recording a macro while you do a Save As and choosing PDF as the File Type? I would think that the VBA Recorder would use whatever commands are valid for the version you have installed.
I just did that on my PC with Excel 2013 and got the following:
BTW…What are these 2 instructions for? They don’t seem to be related to the SaveAs function.
message edited by DerbyDad03