How to Batch Convert Multiple Word Files to PDF

πŸ“… March 22, 2024 ⏱ 8 min read How-To Word to PDF Automation
Advertisement

If you've ever faced a folder containing dozens or hundreds of Word documents that all need to become PDFs, you know the pain of doing them one by one. Each manual conversion takes 30–60 seconds β€” manageable for five files, tedious for twenty, and completely impractical for hundreds. Here are four ways to convert Word files to PDF in bulk.

Method 1: Microsoft Word Macro (VBA)

If you have Microsoft Word installed, a short VBA macro can convert an entire folder of Word documents to PDF automatically. Here's how:

  1. Open Microsoft Word.
  2. Press Alt+F11 to open the VBA editor.
  3. Go to Insert β†’ Module and paste the following code:
Sub BatchConvertToPDF()
Dim folderPath As String
Dim fileName As String
folderPath = "C:\Your\Folder\Path\" ' ← Change this
fileName = Dir(folderPath & "*.doc*")
Do While fileName <> ""
Dim doc As Document
Set doc = Documents.Open(folderPath & fileName)
doc.ExportAsFixedFormat folderPath & Replace(fileName, ".docx", ".pdf"), wdExportFormatPDF
doc.Close False
fileName = Dir
Loop
MsgBox "Done! All files converted."
End Sub

Change the folderPath to your actual folder, then press F5 to run. The macro opens each Word file, exports it as PDF to the same folder, and closes it. For 100 files, this typically takes 5–10 minutes unattended.

Method 2: PowerShell Script (Windows)

PowerShell can automate Word via COM automation. This script converts all DOCX files in a folder:

$word = New-Object -ComObject Word.Application
$word.Visible = $false
$folder = "C:\Your\Folder"
Get-ChildItem $folder -Filter "*.docx" | ForEach-Object {
$doc = $word.Documents.Open($_.FullName)
$pdfPath = $_.FullName -replace "\.docx$", ".pdf"
$doc.SaveAs([ref]$pdfPath, [ref]17) # 17 = wdFormatPDF
$doc.Close()
}
$word.Quit()

Save this as a .ps1 file and run from PowerShell (you may need to enable script execution with Set-ExecutionPolicy RemoteSigned).

Method 3: Python with python-docx and LibreOffice

For cross-platform automation, Python combined with LibreOffice's headless mode is highly effective:

import subprocess
import os
folder = "/path/to/your/folder"
for filename in os.listdir(folder):
if filename.endswith(('.docx', '.doc')):
filepath = os.path.join(folder, filename)
subprocess.run(['libreoffice', '--headless', '--convert-to', 'pdf', '--outdir', folder, filepath])

This requires LibreOffice to be installed. It works on Windows, Mac, and Linux.

Method 4: Command Line with LibreOffice

LibreOffice can be run directly from the command line to convert files:

libreoffice --headless --convert-to pdf *.docx

Run this command in the folder containing your Word files. LibreOffice will convert all matching files to PDF in the current directory. This single command can process hundreds of files. The quality is slightly lower than Microsoft Word's native output but is excellent for most purposes.

Handling Different File Types in Batch

Your batch conversion script should handle both .doc and .docx files. The older .doc format (Word 97–2003) requires the same conversion but some tools handle it differently:

Logging and Error Handling

For production batch conversion, add error handling to your scripts. Some Word files may be corrupted, password-protected, or in use by another process. A robust script should:

Performance Benchmarks

Method100 Files (~1MB each)QualityPlatform
Word VBA Macro~8 minutesExcellentWindows
PowerShell + Word~8 minutesExcellentWindows
Python + LibreOffice~12 minutesVery GoodAll
LibreOffice CLI~10 minutesVery GoodAll

Need to Convert a Single File Right Now?

For one-off conversions, our free online tool is the fastest option β€” no setup required.

Convert Word to PDF β€” Free
Advertisement

Related Articles