Skip to content

Instantly share code, notes, and snippets.

@kebien6020
Last active April 25, 2018 14:05
Show Gist options
  • Save kebien6020/5d92f58af66d16f8418d5c3f84b5a29a to your computer and use it in GitHub Desktop.
Save kebien6020/5d92f58af66d16f8418d5c3f84b5a29a to your computer and use it in GitHub Desktop.
Excel macro to Instantly export as pdf in the same folder
Sub ExportAsPDF()
'Instantly export as pdf in the same folder
Dim filename As String
filename = ActiveWorkbook.FullName
filename = Replace(filename, ".xlsm", ".pdf")
filename = Replace(filename, ".xlsx", ".pdf")
filename = Replace(filename, ".xls", ".pdf")
filename = Replace(filename, ".xlb", ".pdf")
ActiveWorkbook.ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
filename, Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment