VBA & Macro Problems

How to Save Word Documents as PDFs Without Prompts Using VBA

Tauseeq MagsiTauseeq Magsi Oct 20, 2026 871 views

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.

How to Save Word Documents as PDFs Without Prompts Using VBA
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 you start

Before modifying your macro, ensure you have enabled Developer tools in your word processor and saved a backup of your original document.

Solution 1Recommended

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.

1
Open the VBA Editor

Press `Alt + F11` on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Locate the Macro Script

In the left-hand Project Explorer, find and double-click the module containing your PDF conversion macro.

3
Find the Document Close Command

Scroll through your code to find the line that closes the temporary document. It usually looks like `Target.Close` or `ActiveDocument.Close`.

4
Add the SaveChanges Parameter

Modify this line to include the save parameter. Change it to `Target.Close SaveChanges:=False` (or `ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges`).

5
Save and Run

Save your script and run the macro again. The document pages will now be exported to PDF silently without any interruptions.

Modify the VBA Macro to Suppress Save Prompts
Automation Achieved: Your macro will now process all pages continuously without requiring manual clicks for each generated file.
Efficient PDF Export with WPS Office

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. 1. Open your Document in WPS: Launch WPS Writer and open the document you wish to convert to PDF.
  2. 2. Run your VBA Macro: Navigate to the 'Developer' tab, click 'Macros', select your updated script, and click 'Run'.
  3. 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.
Highly compatible with Microsoft Word documents (.docx) and VBA macros.Built-in 'Export to PDF' feature for quick, script-free conversions.Lightweight software that runs smoothly without lagging your device.Familiar user interface makes transitioning from Microsoft Office effortless.
microsoft office alternative - wps office

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.