Use word document as template in sharepoint



This article is all about to use word document as template. We are going to use the content type, list, associated libraries and shareopint designer workflow.


We have requirement like whenever user add any item in list, system will automatically generate the word document based on template file (Predefined format).


1) Create one custom list : Here in example, we have below custom list (Customer) having columns (Title, Firstname, Last Name). Below list will work as interface for user to add customer information in to sharepoint.

2) Create two document library : Here in example, we will use below two library (CustomerTemplateLib and CustomerInformationLib).

  • CustomerTemplateLib : We are going to use it as template library to hold template file.
  • CustomerInformationLib : All the word documents generated based on template file will store over here.

3) Create one content type : A purpose of create content type to associate columns to both the library and template file to (CustomerInformationLib) library.

  • Create content type as below : We are using “Document” as parent content type.

  • Now we are going to create same identical column as our “Customer” list with slightly difference of prefix ahead of column name in content type.
  • Click on “Customer_Content_Type” -> Choose “Add from new site columns” -> create site columns as customer list with “CT_” prefix (CT_FirstName and CT_LastName). After create columns, content type will looks like below.


4) Apply content type in both the library as primary content type. Apply below steps to both the library.

  • Goto library settings -> Advanced settings -> set “Allow management of content types”.
  • Above step will show content types section on library settings page.
  • Choose “Add from existing site content types” -> select “Customer_Content_Type” -> Add it into library content types.
  • Set “Customer_Content_Type” as primary content type by clicking on “Change new button order and default content type” -> Uncheck “Document” content type -> Press “Ok”.
  • Library settings will look like below.

5) Time to create template document:

  • Create on word document with specific predefined text and upload it in to “CustomerTemplateLib”.
  • In “CustomerTemplateLib” click on template document -> It will download in case of “On premise” and ask for edit in “online” -> Edit template document in installed microsoft word on your machine.
  • Now word file has one option in INSERT menu called “Quick parts”. We are going to use it for add document properties (CT_FirstName and CT_LastName).

  • Set document properties field to appropriate place and upload it back to template document library (CustomerTemplateLib) in case of on-premise.

6) Set our template file as existing document template in content type:

  • Open “Customer_Content_Type” content type -> select “Advanced settings” -> set path of our custom template which is upload in “CustomerTemplateLib” into “Enter the URL of an existing document template”.

  • Till now we have setup all required things to generate document in library (CustomerInformationLib) with specific template. If you want to check all steps are performed well you could manually upload template document in “CustomerInformationLib” and set all document property (columns:- Title, FirstName, LastName) by edit document properties. After set value in document properties (columns), you will see the value of property visible in document.
Note: Above point is only for manual check wheather document properly generates or not. In real world scenerio no one will manually create document in library and setup the properties.

Now, We are going to focus on create sharepoint designer workflow.

Purpose for below steps: Whenever user enters any customer detail into “Customer” list one workflow will trigger and it will create document in “CustomerInformationLib”.

1) Open specific site in sharepoint designer -> Goto “Workflows” -> Choose “List Workflow” from ribbon -> Choose custom list “Customer” -> Give it proper name -> Choose platform type “Sharepoint 2010 workflow”.

      Note:- select sharepoint 2010 workflow as platform type. Don’t know the reason but 2013 template platform doesn’t work properly.

2) Put “Create item in” activity on design surface -> choose “CustomerInformationLib” in list -> set properties according to it. Below image shows configuration for “Create item in”.

Note: Do not forgot to set content type id as “Customer_Content_Type”.

3) Save it and publish it. You can setup the workflow run automatically when item created in “Customer” list.

Now we can test the developed work.

1) Enter one item in “Customer” list.

2) If workflow setup as “automatically run when item created” it will executed otherwise we have to manually run it.

3) Check “CustomerInformationLib” document library, it will have document with proper values as predefined template.

Note: User should have proper permission on list and library to generate the document.

Next article, I will show you how to solve empty property issue (Blank instead of field name) in generated document.