Using SharePoint Metadata in Word Documents – The Lookup Column Issue

Using Word templates in combination with Content Types in SharePoint gives a user a rich experience in using SharePoint metadata in the content of a Word document.

For example: if you are making the meeting minutes for a certain meeting, you would like to have the Meeting Date as meta data of the document, but that same Meeting Date is probably also used in the minutes document itself somewhere.

So we could insert meta data columns as Document Property Quick Parts in the Word document. That way, entering the meta data information in the document information panel, will automatically update the Quick Parts in the document itself as well. If you have never done this before, no worries, I will show you how this works later on.

Now this all works well for SharePoint columns of every type, but lookup columns. Lookup columns have a typical way of storing data. What is you see is not what you get. When you use a lookup column to a SharePoint list, what you see as meta data is the Title field of that SharePoint list, but the value of the lookup column is actually the item ID of the list item you select in your lookup column. So when you insert this lookup column Document Property as a Quick Part in your Word document, not the Title field is shown in your document, but the item ID.

What I will describe in this blog posting is a way to work around this problem.

Let’s take the meeting minutes document as an example again. A typical minutes document could look like this:

Now what we would like as meta data of this document is the subtitle (let’s use the Title field for this), the Meeting Date, and the associated Project the meeting was held for. So let’s create a Content Type called Meeting Minutes as the screenshot below:

What you can see already, is two columns for the Project meta data. This is necessary for my work around to work, as you’ll see later on.

Under Advanced settings, upload your Word template for your meeting minutes.

Now we will create a custom Document Information Panel in InfoPath. Click Document Information Panel settings. Click Create a new custom template.

This will fire up InfoPath. InfoPath will first tell you that it will create a form template for your custom content type, and you need to publish the template if you’d like to use it. Duh! Click Finish. And there you have your Document Information Panel.

What we need to do, is have the Project field automatically updated when you choose a project from the Project Lookup. Do this as following: Double click the Project text box. In the Text Box Properties window, click the fx button next to Value. Click Insert Field or Group…. In the Data source drop down, select the data source starting with list_, and select the Title dataField.

We need to filter the Title value. Click Filter Data… and next Add… In the first drop down select ID, then is equal to, then select a field or group… Now choose the Main data source and select the Project dataField.

Click a few times OK, until all windows are closed, and you’re back at your InfoPath form.

 

 Before you close the last window, you could also decide to make the Project field read-only:

 

Save your InfoPath form (File –> Save as), and then publish it (File –> Publish), Next, Publish, Close.

Now we are going to add the meta data as Quick Parts in your Word template. Attach the new Content Type to a Document Library of your choice and start a new Word document from this Content Type.

On the Insert ribbon, click Quick Parts, then Document Property, and then insert the properties you like on the places in your document of your likings. The document will look like this:

Be sure to insert the Project property and not the Project Lookup property. If you insert the Project Lookup property, you will see the ID of the project will be inserted in your Word document, instead of the name of the project.

Finally, save this document and re-upload it as the template in your Content Type.

Now you have a SharePoint Content Type with a Word template attached, where Word content and meta data are in sync.

6 Responses to “Using SharePoint Metadata in Word Documents – The Lookup Column Issue”

  1. Khushi says:

    Hey Marteen, Eekel’s

    I am bit confused with your article.
    First part of confusion
    As per your article,
    1. First create a document library and add metadata to it.
    2. Upload the word template.
    3. Create a document Panel in InfoPath and then. Click Document Information Panel settings. Click Create a new custom template.
    Confusing point — We uploaded the word template and also creating new custom template. When there are radio buttons to select either of them. How do we do both the steps together?
    I am sorry may be I am not getting your point. Could you please explain?
    Also, could you please elaborate creation of document Panel for our own custom content type in detail steps?
    4. In the above step we were making document panel then how and where did we created content type. As your next step says
    5. Attach the new Content Type to a Document Library of your choice and start a new Word document from this Content Type.
    I just got the last part that as soon as we attach new content type to document lib Quick part will appear.
    Second Part of confusion
    Confusion is with your and the Steve Hanson’s article http://blogs.officezealot.com/hansen/archive/2006/10/19/14129.aspx. Fortunately or Unfortunately I read Hansen’s article first and I tried his steps which doesn’t provide much information or redirect to any resources.
    1. First create content type and add columns to it.
    2. Create document and asscociate with content type.
    3. Create a document library that uses the Hello Word content type
    4. Bind the content type fields to content controls in Word.
    5. Upload the new bound version to the content type
    I appreciate your efforts on the post because ID was appearing instead of value, was one of the issues I was facing.
    The other issue I am facing is I have a column of type RichText .
    The content in the word document is showing html tags instead of richtext format.
    I mean when I enter viz. “some italic text is in red” in sharepoint list and open word document. Word document shows “someitalic text is inred”.
    How do I show rich text in a word document?
    I would appreciate if you please reply me asap.
    Could you mention your twitter/hotmail for instant messaging.
    Thanks & Regards
    Khushi

    • Hi Kushi,

      Your step 1 is already not correct. I am talking about creating a content type, not a document library.

      Then, under Advanced settings, upload your Word template for your meeting minutes. And under Document Information Panel settings create a new custom template for your properties.

      So first you create a content type with all your necessary properties, then you upload your Word template, and then create your document information panel.

      Should work this way ;-)

      Regarding the new document information panel not showing up: you need the InfoPath client installed on the client side where you open Word with your new template.

  2. Gene says:

    thanks a lot for this post!

  3. Dean says:

    Thanks for the info, I tried to implement this technique in a slightly different manner and would like to share what I learned. I tried to modify the DIP in the Contents Type gallery and use a separate doc library for my templates (as opposed to the approach above in which the template is uploaded to the CT gallery). I then activated the content type in DocLibrary in a subsite but got a DIP can’t be loaded error. I was able to fix this by modifying the DIP in the DocLibrary that contains my templates. Now I can have one library with templates that can be easily edited without having to go to the CT gallery.
    Dean

  4. Eloy says:

    Is it posible to upload a such template (or document) to see what does it change (inside the .docx (zip) in the xml) so then could be implemented to make such modifications without using sharepoint or infopath…

    It is realy interesting it to make templates, but this way is toooo long to me (and I have not infopath nor sharepoing)

    thanks for all

    • Hi Eloy,

      This whole post is about the combination of SharePoint metadata and Word documents. If you’d like to make such modifications to your Word document without SharePoint or InfoPath, just use the Quick Parts functionality of Word on the Insert ribbon.

Leave a Reply