VBA & Macro Problems

How to Use VBA to Prompt Save As Dialog and Save Word Form as DOCX

John WilsonJohn Wilson Nov 3, 2026 869 views

Question details

The user needs a VBA script to display a Save As dialog in Word, allowing a completed document generated from a UserForm to be saved as a standard DOCX file instead of a macro-enabled format.

Use VBA to Display Save As Dialog and Save Word Form as DOCX
Product
Word
Device & OS
not provided
Scenario
A user is filling out a Word UserForm that populates bookmarks in a newly generated document, and the macro must prompt the user to save the resulting file as a macro-free DOCX document.
Observed behavior
The user wants to ensure the document saves correctly as a DOCX without retaining the macro-enabled properties of the source template, avoiding any macro security prompts for the final recipient.
Before you start

Before modifying your VBA code, ensure your original document is saved as a Macro-Enabled Template (.dotm) so that newly generated documents do not inherit macros by default. Also, verify that the Developer tab is enabled in your Word ribbon.

Solution 1Recommended

Use the wdDialogFileSaveAs VBA Method

This method directly calls Word's native Save As dialog and forces the file format to standard DOCX.

By utilizing the Dialogs(wdDialogFileSaveAs) object, you can pre-define the output format before showing the prompt to the user. This ensures the saved file is a standard, macro-free Word document (.docx).

1
Access the VBA Editor

Open the VBA editor by pressing Alt + F11 and locate your UserForm code in the Project Explorer.

2
Locate the submit button code

Navigate to the end of your submit button's procedure (e.g., CommandButton1_Click), placing your cursor after the form values are written to the document and the form is hidden.

3
Insert the Save As code

Type the following code block: With Dialogs(wdDialogFileSaveAs) .Format = wdFormatXMLDocument .Show End With

4
Test the macro

Run the macro. The Save As dialog will now appear with 'Word Document (*.docx)' pre-selected as the file type.

Use the wdDialogFileSaveAs VBA Method
Code Placement: Always place this code after 'Me.Hide' or 'Unload Me' in your UserForm to ensure the form UI does not interfere with the dialog box.
Advanced Document Automation with WPS Office

Create and Save Macro-Enabled Forms in WPS Writer

WPS Office supports VBA macros, allowing you to create complex UserForms, automate document generation, and prompt custom save dialogs just like Microsoft Word.

  1. 1. Enable the Developer Tab: Open WPS Writer, go to the settings or options menu, and ensure the Developer tab is enabled to access macro tools.
  2. 2. Open the Visual Basic Editor: Click on 'Visual Basic Editor' under the Developer tab to build your UserForm and insert your VBA automation scripts.
  3. 3. Apply the Save As VBA Code: Apply the Dialogs(wdDialogFileSaveAs) code to your form's command button to ensure the final output is forced to standard DOCX.
  4. 4. Save and Run: Save your master document as a Macro-Enabled Template (.dotm) and run your macro to generate and save standard .docx files effortlessly.
Seamless compatibility with Microsoft Word .dotm and .docx formatsBuilt-in VBA editor for creating customized UserForms and macrosLightweight application with high performance for document automationFree to download and highly cost-effective for enterprise use
microsoft office alternative - wps office

Frequently Asked Questions

Why does my saved file still prompt about macros on Mac?

This can happen if the document was inadvertently saved as a .dotm file despite the dialog. Ensure that '.Format = wdFormatXMLDocument' is explicitly declared in your VBA code before showing the Save As dialog, and double-check Mac-specific permissions.

Can I pre-fill the file name in the Save As dialog using VBA?

Yes, you can set a default file name by adding '.Name = "YourDesiredFileName.docx"' inside the 'With Dialogs(wdDialogFileSaveAs)' block right before the '.Show' command.

Does saving as wdFormatXMLDocument remove macros from the file?

Yes, saving a file as wdFormatXMLDocument (which corresponds to the .docx extension) strips out any VBA code and UserForms, resulting in a clean, macro-free document.

Why isn't the file saving after I click Save in the dialog on Windows?

The '.Show' method only displays the dialog; it usually executes the default action automatically. If it fails, capture the return value of '.Show' or use '.Execute' instead, or implement 'ActiveDocument.SaveAs2' to handle the actual saving process programmatically.