Automate the process of exporting Microsoft Word documents to PDF on macOS. This script exports the currently open Word document (including unsaved changes) to PDF, replacing the existing PDF file.
Frequent small changes to Word documents and need to export them as PDFs. The manual process involves:
- Press cmd+shift+s
- Select PDF format
- Click export
- Click replace
This automation reduces it to a single keyboard shortcut or button click.
- Exports active Word document to PDF (even with unsaved changes)
- Warns if no existing PDF exists (prevents accidental file creation)
- Works with any Word document
- Can be triggered via keyboard shortcut or Dock icon
- macOS
- Microsoft Word for Mac
- Python 3
-
Clone this repository: git clone https://github.com/MusaOzcetin/export_replace.git
cd export-replace-automation
-
Make the script executable: chmod +x export_replace.py
-
Update the script path in your setup (if different from default location)
python3 export_replace.py
The script uses AppleScript (via Python's subprocess) to:
- Get the currently active Word document
- Check if a PDF with the same name exists
- Export the document to PDF using Word's native export function
- Show a notification when complete
MIT License - feel free to use and modify as needed.
Musa Ozcetin