VBA macro print as PDF

A very helpful VBA macro that turns any printable excel document into a PDF file.

Convert excel to pdf or save excel to pdf

Excel to pdf

Sub savepdf()
mo= Month(Date)
d = Day(Date)
y = Year(Date)
h = Hour(Now)
m = Minute(Now)
s = Second(Now)

file= y & mo & d & “-” & h & m & s & “.pdf”
Sheets(“sheet1”).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
file, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
True

End Sub

 

Write a Reply or Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.