Eagle-eyes Bakerman2 well spotted and all is perfect. We are doing tests as we speak and so far is looking good. The polished Macro is:
Sub Save_and_print()
'
' Save pdf as cell reference
'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"\\WDMYCLOUD\Euromatic\Invoices\" & Range("G3") & ".pdf", Quality:=xlQualityMinimum, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, From:=1, To:=1, _
OpenAfterPublish:=True
'
' Set the active Printer
'
Application.ActivePrinter = "Canon MG6200 series Printer on Ne01:"
'
' Print desired number of copies from a cell
'
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=Range("K4").Value, Collate _
:=True, IgnorePrintAreas:=False
End Sub
The only comment is per the earlier thread and making it idiot proof because if a pdf file with the same name already exists in the directory then the macro will overwrite without warning. I tried to write a line starting
If FileExists("\\WDMYCLOUD\Euromatic\Invoices\" & Range("G3") & ".pdf") then MsgBox...
but this fails and have no idea how to put up a warning message box even though I understand partly the
MsgBox(Prompt,[Buttons As VbMsgBoxStyle = vbOkOnly],[Title],[HelpFile],[Context]) As vbMsgBoxResult
Can anyone help on this so I can publish in case anyone else want to use it?
Bookmarks