WORD TO PDF - NO NEED OF OTHER PROGRAMS

Contains tips for configurators working with Aware IM
Post Reply
yuri.rj
Posts: 223
Joined: Tue Jan 11, 2011 8:05 pm

WORD TO PDF - NO NEED OF OTHER PROGRAMS

Post by yuri.rj »

I was reading some posts about this and found that (i believe) no one could print a DOC(word document) to pdf withou using another program, and yet some problems could help.

I want to share a solution to this without need to do any of this:

1) The document used on the AwareIM Template has to be a macro ready document and needs to have this macro:

Code: Select all

' The Word macro for exporting to PDF (the Word window closes after finishing)
Sub ExportToPDFext()
    ActiveDocument.TablesOfContents(1).Update
    ChangeFileOpenDirectory ThisDocument.Path
    ActiveDocument.ExportAsFixedFormat _
        OutputFileName:=Left(ActiveDocument.FullName, InStrRev(ActiveDocument.FullName, ".")) + "pdf", _
        ExportFormat:=wdExportFormatPDF, _
        OpenAfterExport:=False, _
        OptimizeFor:=wdExportOptimizeForPrint, _
        Range:=wdExportAllDocument, _
        From:=1, _
        To:=1, _
        Item:=wdExportDocumentContent, _
        IncludeDocProps:=True, _
        KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, _
        DocStructureTags:=True, _
        BitmapMissingFonts:=True, _
        UseISO19005_1:=False
    Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub
2) In word(on the server which will process this document) the security must be available to execute macros and trust documents.

3) A EXECUTE PROGRAM using this command lines on Word, will do the thing.

Code: Select all

"C:\Program Files\Microsoft Office 15\root\o
ffice15\WINWORD.EXE" /mExportToPDFext /q "YOURDOCUMENT.doc"
/m parameter executes the macro
/q don't show the splashscreen and don't show word

And the macro already have a line to update tables of contents so your documents keeps updated after being processed by aware.

Cheers.
hpl123
Posts: 2594
Joined: Fri Feb 01, 2013 1:13 pm
Location: Scandinavia

Re: WORD TO PDF - NO NEED OF OTHER PROGRAMS

Post by hpl123 »

Very nice solution Yuri. Thanks for sharing :).
Henrik (V8 Developer Ed. - Windows)
Post Reply