Reputation: 57
I am new to VBA and still trying to learn this day by day. I need to print my opened workbook with a .PDF format but without prompting the print dialog box(Destination folder). Instead, I want to format a destination path in the code and also with some page setups(orientation,zoom,etc). How do I solve this?
Sub PrintDoc()
Sheets("Sheet1").PrintOut
End Sub
Upvotes: 2
Views: 1980
Reputation: 5183
You can use the code below to define your destination path and print PDF without prompting the print dialog box and some basic page set-ups.
'Export as PDF
Application.DisplayAlerts = False
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
destinationPath & destinationFilename & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Attribution: Another Stackoverflow answer
Upvotes: 2