Skip to content

Instantly share code, notes, and snippets.

@huangyg11
Last active February 9, 2016 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huangyg11/e57203bbdcc914eb490e to your computer and use it in GitHub Desktop.
Save huangyg11/e57203bbdcc914eb490e to your computer and use it in GitHub Desktop.
Save word to pdf and open it with viewer
Sub SaveAsPdf()
'
'
'
Dim filename As String
filename = ActiveDocument.Path & "\" _
& CreateObject("scripting.filesystemobject").getbasename(ActiveDocument) _
& ".pdf"
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
filename, ExportFormat:= _
wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
Dim a
Dim s As String
s = "e:\SumatraPDF\SumatraPDF.exe -reuse-instance " & Chr(34) & filename & Chr(34)
a = Shell(s, 1)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment