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:


Hamid said...

Could you please tell me where should i put this code? I explored everywhere to find a way to do it but since i have not got a good skill of coding i was not able to do it. Could you please tell me the procedure in more detail about the code. I really appreciate it and it could be very useful.

harry said...


This artical is very useful for me. I am a Share Point developer and always looking to learn something new. I would like to introduce another good SharePoint blog, Have a look.