Using Custom Document Template And Quick Parts To Get Column Values From SharePoint

Quite often, there is a situation when a user wants to save the documents with metadata in SharePoint library. To accomplish this, we can use document template, customize it, and by using Quick parts in Microsoft Office, we can save the metadata in the library and in Microsoft Office documents.

In this article, I am going to tell how we can create a Custom Document Template and use Quick parts in Microsoft Office. Here, I am using Quick parts from Microsoft Word.

  • SharePoint platform - SharePoint Server 2013
  • Microsoft Office 2010.

Step 1

Create site columns and custom content type with parent content type as document and then add the content types to the library. I am explaining this with the help of an example.

Step 2

First, create custom site columns.

  • First name
  • Last name
  • Job title
  • Department
  • Description
  • E-mail
  • Enterprise Keywords
  • Joining date
  • Employee status
  • Employee ID
  • Description

Step 3

Create two content types - HRInfo and EmployeeInfo

Step 4

Add the below columns to HRInfo Content type.

 
Step5

Add the below columns to EmployeeInfo Content type.

 
Step6

Create a document library EmployeeInfo and add both the content types to the document library. From advanced settings, click "Allow Management of content types".

Now, in the below screenshot, we can see EmployeeInfo and HRInfo as the content type.

 

Step 7 - Edit templates and use Quick parts

First, open the Forms folder in File Explorer. For this, we can create a network folder, as shown below.

 

For creating a network path, use http://<Sitename>/<library name>/ Forms as a network path.

Below is our network folder and we can see EmployeeInfo and HRInfo, as two different folders.

 
To edit the template, go into HRInfo folder and edit the template.

 

Now, when we open the template, we can see Document panel above which columns are there what we added to the HRInfo content type.

 

Click Insert => Quick parts. For this, the Developer mode should be enabled.

 
 

Save the template. Now, when we try to save this template, it gives the below message.

 

So first, save this template somewhere on your system and then, replace the template in the HRInfo folder.

 

Step 8

In a similar manner, we can edit EmployeeInfo Template.

Step 9

Save the documents using HRInfo and EmployeeInfo content type. Go to library and click EmployeeInfo.

 

After filling the document properties, we can see whatever we are typing in the properties is also reflecting in the document. After filling in the properties, click Save.

The red boundary is for mandatory field.

 
 

After saving the document, go to documents library and you can see the document visible there.

 
Limitations

Calculated fields will not appear in Quick parts. In Word 2010, multiple checkbox fields actually will not appear in Quick parts.

For people and person field to work in MS Word, we have to make the following changes in Web.config as below.

  1. <system.serviceModel>  
  2.     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />   
  3. </system.serviceModel>  
But after you make the above changes, drag and drop functionality will not work. Enterprise keywords just hang the Word application.

Note

Once we open the document and if the document panel does not appear, enable the Developer mode first and under the Developer tab, the Document panel will be visible.

Up Next
    Ebook Download
    View all
    Learn
    View all