|« Building redir (redir.c) from patched sources||Plesk Mailman cheat sheet »|
Adding custom fields codes to a Word documentJune 18th, 2010
The first page in my documentation is always the title page. You know the sort - big company logo along with the title of the document and a couple of other useful pieces of information for filing like file name, version, last updated date and author. Each one of my pages has headers and footers. The page header contains the title and the version of the document whilst the footer contains the company name with a copyright message and the page number.
As you can see there is repeating information which has to be managed and updated. So often I get documents where the version date is changed on the front page but the author has forgotten to update it in the headers or footers. This is where Microsoft Word Fields come in handy.
A Microsoft Word Field is a property that is tucked away inside the document or is generated by Microsoft Word. The best example of a Field that most people use without noticing is Page Number or Number of Pages. These are just 2 of the really common ones, there are loads and you can create your own.
The documentation is a bit thin which is a bit surprising for Microsoft. I had a look on the interweb for other blogs describing how to add these mystical fields but most of them were pretty complicated and I was left to use good old fashioned trial and error to figure it out. And now that I have I’m telling the world.
So let’s go with my example from the first paragraph. In order to make it easier to see when it’s working lets fill in the property information first. If we don’t do this first after we set up our Field it will be blank and we won’t be able to tell if it is blank because it’s broken or it’s blank because it’s empty.
For Office 2010, Go to File->Info and click the Properties drop down on the right hand side (under the preview of the document)and Advanced Properties.
- From Word’s menu select File->Properties.
- Goto the General tab.
- Fill in as many of the document properties as you can but do include at the very least: Title, Subject, Author, Company.
- Now go to the Custom tab.
- Next to Name enter version.
- Next to Type select Number from the drop down box.
- Next to Value enter 0.1 (or whatever your document version is).
- At this point the Add button will become enabled, so click it.
- version will appear in the Properties: list in the bottom part of the screen.
- Finally click Ok.
You have now added all the information you want in one central place. Next we need to create our front page. We will embed several Fields in it.
- Set up the image in the centre of the page and make it look pretty.
- Under the image we want the document Title, so place the cursor somewhere sensible and set the font and format you want.
- From the menus select Insert->Field…
- Make sure the Category is set to (All).
- Select Title from the field names.
- Choose the Format of the field.
- Click Ok.
- The title of your document will appear, when you click on it, it will appear with a grey background to show it’s a field code.
At the bottom of the screen we are going to write our file and documentation fields.
- First write the text: Document File name
- Next set up the font and format in the way you like for this piece of information.
- From the Insert menu select Field….
- Ensure the Category is set to (All) and select FileName.
- Next write Date and from the field’s menu select SaveDate picking the format you would like the date to be displayed in.
- Getting the idea yet? Next write Author and select Author from the field’s dialogue.
- Finally enter Version. This one is a custom field in the document properties so select DocProperty from the Field names and because we have already set up the version value it should appear in the Property list so select it and press Ok.
In each case when we add the the Field code to the document it will appear updated in the document, with a grey background if you click on it. Now just do the same for the headers and footers and you’re done.
When you change any of your document properties just go into File->Properties make the changes you want. When you return to the document. Highlight the field by clicking on it and from the context menu select Update Field. Unfortunately the header and footer Fields are not covered in the Select All (Control-A) and so must be done separately.