How to Save Word Documents as PDFs Without Prompts Using VBA
Question details
The user wants to use a VBA macro to convert every page of a Word document into individual PDFs without encountering save prompts for temporary files.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Running a VBA macro to batch split and export a Word document into multiple PDF files.
- Observed behavior
- The macro creates temporary documents for each page, but closing them triggers a 'Save, Don't Save, or Cancel' prompt, which interrupts the automated PDF conversion process.
Before modifying your macro, ensure you have enabled Developer tools in your word processor and saved a backup of your original document.
Modify the VBA Macro to Suppress Save Prompts
Add a specific parameter to the document close command in your VBA script to automatically discard changes to temporary files.
When splitting a document into separate PDFs, macros typically copy each page into a new temporary document, export it, and close it. By default, closing a modified document triggers a save prompt.
To prevent this, you can instruct VBA to close the document without saving by using the `SaveChanges:=False` parameter. This mimics the action of clicking 'Don't Save' automatically.
Press `Alt + F11` on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the left-hand Project Explorer, find and double-click the module containing your PDF conversion macro.
Scroll through your code to find the line that closes the temporary document. It usually looks like `Target.Close` or `ActiveDocument.Close`.
Modify this line to include the save parameter. Change it to `Target.Close SaveChanges:=False` (or `ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges`).
Save your script and run the macro again. The document pages will now be exported to PDF silently without any interruptions.

Easily Export and Split Word Documents to PDF with WPS Writer
WPS Writer offers seamless compatibility with Microsoft Word VBA macros, allowing you to run your scripts flawlessly. It also includes powerful built-in PDF tools that eliminate the need for complex coding.
- 1. Open your Document in WPS: Launch WPS Writer and open the document you wish to convert to PDF.
- 2. Run your VBA Macro: Navigate to the 'Developer' tab, click 'Macros', select your updated script, and click 'Run'.
- 3. Use Native PDF Tools: Alternatively, skip the macro entirely by clicking 'Menu' > 'Export to PDF' to use WPS Office's built-in conversion capabilities.

Frequently Asked Questions
Why does my VBA macro prompt me to save every time a document closes?
When a macro creates a new document or modifies an existing one, closing it triggers a default safety prompt designed to prevent data loss. VBA requires explicit instructions, such as `SaveChanges:=False`, to bypass this warning.
Is there a way to suppress all alerts in VBA?
Yes, you can add `Application.DisplayAlerts = wdAlertsNone` at the beginning of your macro to suppress general warnings. However, it is highly recommended to set it back to `wdAlertsAll` at the end of your script to ensure you still receive critical system warnings later.
Does WPS Office support VBA macros?
Yes, specific professional versions of WPS Office fully support VBA macros, offering high compatibility with scripts originally written for Microsoft Office.




