How can I get Word to automatically display the document version number in the Header & Footer?
Article contributed by Dave Rado
Why Versions should be avoided
If you use Versions (File + Versions) to store multiple versions of a document within a single file, then it will only be a matter of time before your document corrupts and you lose all your work. Avoid this feature like the plague - and like Fast Save and Master Documents, which are similarly broken – unless the document is of no importance to you. Taking backups won't necessarily help, because the corruption may creep up on you gradually, and by the time you realise you have a corruption you may have to go back to a very old file to get a clean document.
Creating a custom Document Property
Although there is a built-in Document Property called Revision Number (which you can see if you select File + Properties + Statistics, this is of no use, because it is incremented every time the document is saved. From a Quality perspective, the document revision number (we'll call it the version number from now on to distinguish it from the thing that gets incremented on each save) should be incremented each time a document is redistributed, and not each time it is saved (it could be saved many times during a single editing session).
However, you can create a custom Document Property to store the version number.
Note: If you are a developer, you would do much better to use a Document Variable rather than a Document Property (so that the user can't update the version without using your macros); and to write a version control macro assigned to an “Update Version” button to take care of updating the document variable, the “Last Updated Date”, the revision history and the document's filename (and the filepath, if you have an archive strategy for old versions), as well as taking care of transitions between draft and live status. However, that is outside the scope of this article.
To create a custom Document Property to store the version number:
1. |
Select File + Properties; and then the Custom tab. |
2. |
Where it says Name, type “Version”; where it says Type, select “Number”; and where it says Value, type “1”. |
3. |
Click Add, and OK. |
Then in your Header or Footer, (and on your cover sheet or wherever else you need the version number to be displayed), type the Word “Version”, followed by a space; and:
1. |
On the Insert menu, select Field. |
2. |
From the list of Field Names, select DocProperty |
3. |
Click the Options button, select “Version” in the list of available Document Properties, and click the Add to Field button |
4. |
click OK twice to insert the field. |
You can then copy and paste the field into any other Headers or Footers, and into the cover sheet, as required.
If you now press Alt+F9 to toggle field codes on, you'll see:
{ DOCPROPERTY "Version" }
Press Alt+F9 to toggle the field codes back off, and you'll see the number again.
Alternatively, you could simply have pressed Ctrl+F9 to insert the field braces { } and within the field braces, you could have typed:
{ DOCPROPERTY "Version" }
I only covered the long way round because using the Insert Field dialog doesn't require you to know the correct syntax – it's a very useful dialog, and well worth exploring.
TIP: The Word add-ins DocTools DocPropertyManager makes if fast and easy to work with custom document properties and to insert DocProperty fields. See also the article How properties and DocProperty fields work.
Updating the version number
When you want to update the version number, all you have to do is select the Custom tab of the File Properties dialog again; where it says Properties, click on “Version”, and where it says Value, type the new version number.
If you go into Print Preview, the field will automatically update in the Headers or Footers. Unfortunately, if you also have the field in the main document, (for example, in the coversheet), going into Print Preview won't update it – but printing will, provided that you have Update Fields ticked under Tools + Options + Print. You can also update the field by selecting it and pressing F9. Or you can press Ctrl+A followed by F9 to update all the fields in the main document in one go.