Distributing macros to other users
Article contributed by Jonathan West
So, you are working in a company and you have written some neat macros that make Word easier to use. Now the boss comes along and says “I want you to set up all the PCs in the department with that.”
Ouch! How to do that?
First of all, you need to know where the macros are to start with. Unless you have taken specific action to avoid this, all your macros are probably in a template called normal.dot (see: What do Templates and Add-ins store? for more on this). Your first thought is probably simply to copy your normal.dot to everyone, replacing theirs.
Wrong answer! Normal.dot is Word's “scratch-pad” where many user settings get stored. This includes any macros they have written, any extra menu items or toolbars, keyboard shortcuts, AutoText entries etc. If you mess with those, you are liable to have a riot on your hands. Leave normal.dot well alone.
There are two common ways in which macros get used.
- Macros that are associated with a particular document type, and perhaps have to run automatically when documents of that type are opened or created.
- Macros that need to be generally available at all times.
For the first category, you need your macros to go into the template that those documents are based on. Copy the code to the template. Once you are sure it is working right, you can distribute that template to the users, and put it in their templates folder.
For the second category, you do much the same. Copy the code into a fresh template, along with any additional menu items, toolbars and keyboard shortcuts that you want to set up to make it easier to access the macros. Once you are sure that it is all working, you can distribute that template. This one wants to go into the Word Startup folder. You can find out which folder this is by going to Tools, Options, File Locations, and checking the Startup folder. If the template is copies there, then next time the user opens Word, the macros and toolbars will all be available, because the template is automatically loaded as an add-in.
How can you then distribute any changes you make to your macros in an automated way?
The easiest way (which could be used when you first distribute the templates) is for your IT department to set up a login script that distributes any changes made to your templates and add-ins when users login. They can do this easily, by creating a batch file, containing an xcopy command, and getting the login script to call the batch file. An example of such an xcopy command might be:
XCOPY [server path] [local path] /D /Q /Y /R /I /C /K /S
This copies only new files or files that have changed, without prompting, and overwrites readonly files (they should be readonly); and also copies any new subdirectories, if you create any. Once this is set up, you only need to maintain the server copies, and changes will be distributed automatically.
Your IT department can set up user profiles to ensure that everyone's template path is the same. (Obviously, if they are doing so for the first time, users will need to be warned)!
Some companies point their users' Workgroup Template Path and their Startup path to a location on the server (using user profiles); but this doesn't cater for laptop users, whereas copying changes to users' hard disks does.