Word – Set Microsoft Word template to always save documents based on it to a certain location

microsoft wordmicrosoft-officetemplates

Some of my professors demand very specific formats for papers typed up for their courses. I've created word templates (.dotx files) for these, so I don't have to set up the formatting each time I go to write something.

I already have a template for each of my classes, and have my files organized such that each class has its own directory. I would like to be able to specify a default save location for each template. I know how to set the general default save location for all documents, but I want to change it just for a specific template. Even if there were a way to have it save files generated by the template into the folder the template file resides in, that would be nice. Anybody have any ideas?

Best Answer

One solution is to use a macro-enabled template (dotm) with a VBA macro to replace SaveAs.

An example macro is:

Public Sub FileSaveAs()
    Dim dlg As Dialog
    Dim strSaveFolder
    strSaveFolder = Application.Options.DefaultFilePath(wdDocumentsPath)
    Select Case ActiveDocument.AttachedTemplate.Name
        Case "Woodworking.dot"
            Application.Options.DefaultFilePath(wdDocumentsPath) = "C:\Woodworking"
        Case "Travel.dot"
            Application.Options.DefaultFilePath(wdDocumentsPath) = "C:\Travel"
    End Select
    Set dlg = Dialogs(wdDialogFileSaveAs)
    dlg.Show
    Application.Options.DefaultFilePath(wdDocumentsPath) = strSaveFolder
End Sub

You will still need to attach this macro to Ctrl-S.

If you use a separate template document per user, the above "Select Case" can be simplified to a simple assign in each of the templates.

source

Related Question