How to Use VBA to Prompt Save As Dialog and Save Word Form as DOCX
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.

- 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 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.
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).
Open the VBA editor by pressing Alt + F11 and locate your UserForm code in the Project Explorer.
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.
Type the following code block: With Dialogs(wdDialogFileSaveAs) .Format = wdFormatXMLDocument .Show End With
Run the macro. The Save As dialog will now appear with 'Word Document (*.docx)' pre-selected as the file type.

Rely on Default Template Behavior with ActiveDocument.Save
A simpler approach if your source file is strictly configured as a .dotm template.
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. 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. 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. 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. 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.

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.




