Automatically Save New Microsoft Word Template Documents to a Folder
Question details
Set up a Word template so new documents can be saved to a designated folder.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- A user creates documents from a template and wants them saved in a dedicated folder rather than the default location.
- Observed behavior
- Each new document should prompt for a file name and save to the chosen folder.
Create the destination folder and note its full path. The example below uses a Windows path; the template must be macro-enabled and trusted for its AutoNew macro to run.
Add an AutoNew macro to the Word template
Use a macro-enabled template to prompt for a name and save each newly created document to a specified folder.
AutoNew runs when a new document is created from the template, not when an existing document is opened. The example saves new documents as macro-free .docx files.
In Word, select File > Open and open the template itself. If needed, use File > Save As and choose Word Macro-Enabled Template (*.dotm).
Press Alt+F11 to open the Visual Basic Editor. In the template's project, select Insert > Module.
Paste the following code into the module. Replace C:\Reports\ with the full path of an existing folder, keeping the trailing backslash: Sub AutoNew() Dim folderPath As String Dim fileName As String Dim fullPath As String On Error GoTo SaveError folderPath = "C:\Reports\" fileName = Trim(InputBox("Enter a file name without an extension:")) If fileName = "" Then Exit Sub fullPath = folderPath & fileName & ".docx" If Dir(fullPath) <> "" Then MsgBox "A file with that name already exists. The document was not saved." Exit Sub End If ActiveDocument.SaveAs2 FileName:=fullPath, FileFormat:=wdFormatXMLDocument Exit Sub SaveError: MsgBox "The document could not be saved. Check the folder path and file name." End Sub
Save the .dotm template. If necessary, in Word select File > Options > Trust Center > Trust Center Settings > Trusted Locations and add a folder you control, then place the template there. Trust only templates and locations you know are safe.
Create a new document from the template, for example by double-clicking the .dotm file. Enter a file name without an extension and check the destination folder for the new .docx file.

Create and Save Template-Based Documents in WPS Writer
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility. Open compatible documents, create new files from templates, and choose a destination folder when saving. Word's AutoNew macro behavior is not guaranteed in WPS Writer.

Frequently Asked Questions
Why doesn't the AutoNew macro run?
Check that the macro is in a standard module in the .dotm template and that the template is trusted. AutoNew runs when you create a new document from the template, not when you open an existing document.
Can I use a different destination folder?
Yes. Edit the folderPath line in the Visual Basic Editor and enter the full path of an existing folder. The Windows example requires a trailing backslash.
What happens if a document with the same name already exists?
The example displays a message and leaves the new document unsaved instead of overwriting the existing file. Use File > Save As to choose another name.
Does the new document retain macros?
No. The example saves the new document as a macro-free .docx file. The AutoNew macro remains in the .dotm template.




