Hack 49 Quickly Attach a Workgroup TemplateIt's a rare corporate Word user who knows offhand the location of her Workgroup templates on the network. Word knows where they are, but try attaching one to an existing document, and you get a pop quiz on the subject! Reeducate Word with this hack. In addition to templates stored locally, Word allows you to specify a location for document templates on a network, called the Workgroup templates folder. This feature is especially useful in a corporate environment, where multiple users may share the same set of templates. When you specify a Workgroup templates location (select
Tools The Templates and Add-Ins dialog (Tools Figure 5-8. If you click the Attach button, Word takes you to the User templates folder5.6.1 The Code
Word's Options object has a DefaultFilePath property that represents the value assigned to the User templates folder. If you temporarily set this to the Workgroup templates folder, you also change where you end up when you click the Attach button in the Templates and Add-Ins dialog. This hack uses the techniques described in [Hack #63] . Sub AttachWorkGroupTemplate( ) Dim sWorkgroupTemplateFolder As String Dim sUserTemplatesFolder As String Dim dial As Dialog Set dial = Dialogs(wdDialogToolsTemplates) sUserTemplatesFolder = Options.DefaultFilePath(wdUserTemplatesPath) sWorkgroupTemplateFolder = Options.DefaultFilePath(wdWorkgroupTemplatesPath) If Len(sWorkgroupTemplateFolder) = 0 Then MsgBox "No workgroup templates location has been specified." & vbCr & _ "To specify one, go to Tools -> Options -> File Locations.", _ vbExclamation Exit Sub End If Options.DefaultFilePath(wdUserTemplatesPath) = sWorkgroupTemplateFolder If dial.Display = -1 Then dial.Linkstyles = True dial.Execute End If Options.DefaultFilePath(wdUserTemplatesPath) = sUserTemplatesFolder End Sub The macro ignores the "Automatically update document styles" box in the Templates and Add-ins dialog and updates the styles regardless of the value set in the box. Most corporate users are instructed to update their documents to reflect any changes to the template, but if you'd rather decide manually, remove or comment out the following line: dial.Linkstyles = True
5.6.2 Running the Hack
Put this macro into the template of your choice [Hack #50] and put a button for it on the Tools menu, right below the Templates and Add-Ins button. Rename the button "Attach Workgroup Templates," or something similarly descriptive. |