I'd like to have the fastest way to export my report .docx file to .pdf and distribute it to others whenever I've got a new, updated version.

I'm looking for a command-line approach that automates the following steps that I have to do manually using my mouse so far:

File -> Save as -> Browse for location

What are my command options for a batch file?


Create a global macro in Word 2013:

' The Word macro for exporting to PDF (the Word window closes after finishing)
Sub ExportToPDFext()
    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, _
    Application.Quit SaveChanges:=wdDoNotSaveChanges
End Sub

After that you can convert a Word document to PDF in command line:

"C:\Program Files\Microsoft Office\Office15\WINWORD.EXE" /mExportToPDFext /q "your_document_path.docx"

The Word window will not even show up because it's set to closing after the macro finishes working, and the parameter /q disables the splash window when Word is loading.

Here are the alternative detailed instructions on GitHub. Also, the context menu option allows batch converting even without the command line. It can be added to registry. For DOC and DOCX:

@="Save PDF here"

@="\"C:\\Program Files\\Microsoft Office\\Office15\\WINWORD.EXE\" /mExportToPDFext /q \"%1\""

@="Save PDF here"

@="\"C:\\Program Files\\Microsoft Office\\Office15\\WINWORD.EXE\" /mExportToPDFext /q \"%1\"" 

For a simple command-line tool to batch convert you can use, docx2pdf: https://github.com/AlJohri/docx2pdf/


pip install docx2pdf


docx2pdf myFolderOfWordDocs

Disclaimer: I am the author of this tool.

  • 1
    Easy to install and use; this tool certainly helped me out. Thanks. – JustBaron Jan 29 at 8:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.