El Blanco's Office 2007 Blog

Tuesday, July 03, 2007

Intelligent Document Templates

I had an email from a colleague asking me how to go about creating a document template where the content of the template contains metadata from the content type's metadata. I thought this was valuable to others as I haven't seen anything posted about this, so I thought I'd write this post to explain how to achieve this.

Upon completion, you will have a two-way template where data entered into a document based on the template will populate the document's metadata. Also, metadata entered into a document's properties panel will auto-populate the document's content.

Imagine we have a content type called "Contract" assigned to a document library and that the content type has the following metadata:

  • Contract Number: Number (0 D.P.)
  • Contract Date: Date & time (date only)
  • Customer Name: Single Line of text
  • Contract Duration: Choice (1 year, 3 years, 5 years)

To create an intelligent document template:

  1. Click the "New" button on the document library to create a new document based on the Contract content type – this will fire up Word 2007 and open a blank document of content type Contract.
  2. Save the document locally instead of back into SharePoint, say to the desktop.
  3. Open the "Insert" tab within Word 2007.
  4. Drop down the "Quick Parts" menu, and open the "Document Properties" sub-menu.
  5. Here you will see a list of all the properties of the document, including our custom metadata defined above.
  6. Select the property you are interested in from the menu and a quick part is inserted into the document at the location of the cursor.
  7. Continue this approach to add additional quick parts, then save the document locally again.
  8. Open the settings for the Contract content type (Home Site -> Site Actions -> Site Settings -> Modify All Site Settings -> Site content types, then select the "Contract" content type).
  9. Click on the "Advanced Settings" link for the Contract content type.
  10. Select the "Upload a new document template" radio button and browse to the file we saved locally.
  11. Leave the other settings at their default values and select "OK".
  12. Now go back to the document library where the Contract content type is being used and click the "New" button to create a new document. This new document will be based on the new template and will contain the quick parts that we added previously.
  13. Completing the metadata in the document properties panel will complete the content in the quick parts in the document's content. Likewise completing the quick parts will populate the document's metadata properties.

Hope this all makes sense . . .


  • Hi this works great, the only problem I have is my content type's metadata is a drop down list and when you select from the metadata it doesn't show the text value on the document but the number value and because it's a drop down list you can't update the metadata from the document. Have you come across this and maybe know what to do?

    By Anonymous Anonymous, at 12:12 pm  

  • Hi Anonymous,

    I can't say I've come across this before - I've used drop-downs with no problem . . .

    Anyone else seen this ?

    By Blogger Chris White, at 10:01 am  

  • Hi.

    By drop down, I meant a column of type look up. As I'm sure you know, look up values are stored as [ID];#[value]. If I select an item from the drop down in the properties ribbon, I just get the ID in the word doc. And if I try typing anything into the property in the word doc, I get an error saying it can't find that item.

    Hope that clarify's the problem. Thanks for your help!

    By Anonymous Anonymous, at 10:43 am  

  • It has something to do with the showfield property of you're lookup field

    By Anonymous Anonymous, at 1:29 pm  

Post a Comment

<< Home