I have created a macro to export the sheet template to PDF:
ActiveWorkbook.Sheets(\"Sheet2\").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ActiveWorkbook.
if you have adobe printer installed then just use below code to get a pdf
sub Sample()
ActiveWorkbook.Sheets("Sheet2").Activate
ActiveSheet.Printout
End Sub
Your actual code works for me. However try this (TRIED AND TESTED)
Sub Sample()
ActiveWorkbook.Sheets("Sheet2").Activate
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=ActiveWorkbook.Path & "\Survey Report.pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
Note:
Sheet2
has something in it to print else a blank sheet will give you the error.ActiveWorkbook
to ThisWorkbook
and try again...I also got this error and tried doing it manually to work out the problem.
Turns out that you can't save as PDF when the filename (including path) is longer than 218 characters.
You also must have Excel's free Microsoft Save as PDF or XPS add-in installed.