Thursday, 17 April 2008

How to add the SharePoint versionnumber in your Word 2003 / 2007 document?

You shoud think this is possible out of the box, but no luck ... The SharePoint version field is not exposed in Word 2003 or 2007. The reason is that the version field is not a default text field. So you need to look for a workaround, the most easy way is to create your onw "DocumentVersion" text field and copy the value of the SharePoint version field into the new "DocumentVersion" field with code. You need to execute this piece of code after the document has been added (ItemAdded) or updated (ItemUpdated):

This is a sample:

public override void ItemAdded(SPItemEventProperties properties)
SPListItem item = properties.ListItem;
item["NameOfYourNewField"] = item["Version"];

Here you can find the full blogpost about adding the version field in Word 2003:

If you want to know how to add the field in Word 2007, check here: