4

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?

1 Answer 1

3
+50

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

3
  • This looks quite promising; I've experimented with it a bit and it seems to partially work. I'm curious as to the necessity of the select statement; it seems unnecessary if you specify the setting in each template. Is there a way to set the save location to be the same directory as the template is saved in, rather than hard-coding a path?
    – nhinkle
    Oct 19, 2010 at 7:45
  • ActiveDocument.AttachedTemplate.path looks useful.
    – harrymc
    Oct 19, 2010 at 9:14
  • I haven't finalized my solution quite yet, but this looks like the right path to pursue, and got me most of the way there, so I'm giving you the bounty and marking it accepted. Thank you very much for your help!
    – nhinkle
    Oct 23, 2010 at 23:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .