Windows 7 batch command-line to save as .pdf file for word 2013 .docx 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, _
UseISO19005_1:=False
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:
[HKEY_CLASSES_ROOT\Word.Document.8\shell\SavePDFhere]
@="Save PDF here"
[HKEY_CLASSES_ROOT\Word.Document.8\shell\SavePDFhere\command]
@="\"C:\\Program Files\\Microsoft Office\\Office15\\WINWORD.EXE\" /mExportToPDFext /q \"%1\""
[HKEY_CLASSES_ROOT\Word.Document.12\shell\SavePDFhere]
@="Save PDF here"
[HKEY_CLASSES_ROOT\Word.Document.12\shell\SavePDFhere\command]
@="\"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/
Install:
pip install docx2pdf
Run:
docx2pdf myFolderOfWordDocs
Disclaimer: I am the author of this tool.