Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted
+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

share|improve this answer
    
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 '10 at 7:45
    
ActiveDocument.AttachedTemplate.path looks useful. –  harrymc Oct 19 '10 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 '10 at 23:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.