The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Convert a folder of Word docs into PDFs

To convert a folder full of Word documents (.doc or .docx) into PDFs, here’s a simple guide using different methods depending on your setup:


Method 1: Using Microsoft Word (Windows) with VBA Script

If you have Microsoft Word installed on Windows, you can automate the conversion with a VBA macro:

  1. Open Word, press Alt + F11 to open the VBA editor.

  2. Insert a new module (Insert > Module).

  3. Paste this code:

vba
Sub BatchConvertDocsToPDF() Dim folderPath As String Dim fileName As String Dim doc As Document folderPath = "C:PathToYourFolder" ' Change this to your folder path fileName = Dir(folderPath & "*.doc*") While fileName <> "" Set doc = Documents.Open(folderPath & fileName) doc.ExportAsFixedFormat OutputFileName:= _ folderPath & Replace(fileName, ".docx", ".pdf"), _ ExportFormat:=wdExportFormatPDF doc.Close False fileName = Dir() Wend MsgBox "Conversion complete!" End Sub
  1. Modify the folderPath to your folder location.

  2. Run the macro (F5).

  3. All Word files in the folder will be saved as PDFs in the same folder.


Method 2: Using Python with python-docx and comtypes (Windows)

Python can automate Word to PDF conversion via COM interface on Windows:

python
import os import comtypes.client def doc_to_pdf(doc_path, pdf_path): word = comtypes.client.CreateObject('Word.Application') word.Visible = False doc = word.Documents.Open(doc_path) doc.SaveAs(pdf_path, FileFormat=17) # 17 = wdFormatPDF doc.Close() word.Quit() folder = r"C:PathToYourFolder" for filename in os.listdir(folder): if filename.endswith(".doc") or filename.endswith(".docx"): doc_file = os.path.join(folder, filename) pdf_file = os.path.join(folder, os.path.splitext(filename)[0] + ".pdf") doc_to_pdf(doc_file, pdf_file) print("All files converted.")

Make sure to have Python and comtypes installed (pip install comtypes).


Method 3: Using LibreOffice (Cross-Platform)

LibreOffice can convert docs to PDFs via command line:

bash
soffice --headless --convert-to pdf *.docx --outdir /path/to/output/folder

Steps:

  • Install LibreOffice.

  • Open terminal or command prompt.

  • Navigate to your folder with Word docs.

  • Run the command above.

  • PDFs will be created in the specified output directory.


Summary

  • Windows + MS Word: Use VBA macro or Python COM automation.

  • Cross-platform: Use LibreOffice command line.

  • Batch process by pointing scripts to the folder location.

Let me know if you want the code customized for your OS or need help running these!

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About