Blog written by:
CCNA, MCPD, MCTS, A+
Organizations seldom take advantage of using document templates to create or add a new document in SharePoint Document Library, although this feature has been available since SP2007.
There are several advantages of creating a SharePoint document automatically via a template, especially when a preferred outline needs to be used for say, creating a marketing campaign or a business proposal. While a template ensures consistency, users also can save time on building the format of the document as prescribed by the organization.
Let’s say you want to create a new sales quote with the existing template you have in Word format. What you would do out of habit is, open the Word template, make changes as per your new quotation and then save that new file in SP document library. However, SharePoint has features that will save your time and get the exact same result in a more efficient manner. SharePoint has a functionality that allows you to create a new document directly from the document library based on the defined template for that library. You can define a template by making changes to the default template and using that pre-formatted template to create new versions of your sales quotes.
Templates are useful when creating forms too. For example, an expense form or a training request form in MS Word can simply be added by a user based on a previously uploaded file in the Document Library and by clicking “Add New Expense Form”.
There are three ways in which users can leverage the concept of templates in SharePoint. (i) by using a library template, (ii) by using a content type template and (iii) using a library to manage the Document templates.
While the library template is very easy to use, it limits the users in the sense that all the documents contained in the particular library need to necessarily use the defined metadata in that library. So, the usage of the library template is restricted and can’t be used anywhere else in the site or site collection. To overcome this problem, SharePoint 2007 brought in the concept of ‘Content Types’, which simply put is a collection of metadata fields that may be applied to the document.
Let’s talk about the various steps involved in creating a new content type in user-interface and then adding it to a document library.
Step 1: Create the Content Type
Content types are basically created at the site / site collection level; hence, they are available within the site as well as the sites below them. If created at the root of the site collection, the content type would be available to the entire site collection.
In order to do this, go to the root site, select “Site Actions” -> Site Settings
Now, got to the Content Type Gallery, where all the content types are stored. And select “Site Content Types”.
Let’s say you want to create a template for Letter – type in “Letter” in the content type and click the “Create” button. Now, this “Letter” with all the inherited properties like Name, Title etc. from the “Document” content type is ready to be termed as a group by selecting the “My Custom Types” group. Upon creating the “Letter” content type, you can add all required custom fields to this content type.
Step 2: Add Metadata to the Content Type
Metadata is a fancy word for a ‘column’ or ‘field’, such as a person’s name or age. A ‘Content Type’ will store a collection of these fields/metadata. Essentially, we use metadata to capture extra information about a document that helps with search and describes information about the document. Adding metadata involves creating columns in the Content Type Information Page. If a column name is already in use, then you need to create a new name. It’s advisable to put all new columns in one group for easier updating when required.
Once the new Content Type “Expense Report” is created, click ‘Add from new site column’ to add metadata/fields that relate to this ‘Expense Report’. For example, you may want to capture ‘Expense Date’ or ‘Expense Amount’. NOTE: You could also use existing columns (if you created ones before) or use ones that are present by default from SharePoint.
I added 3 below for this example:
Step 3: Creating and Uploading Word File
This is required because in Content Types, the document template is not automatically created when the content type is created. This also allows us to upload a ‘Company Branded’ file, which we may already have handy.
To make it simple, I will start with a very simple MS Word file and then edit it after. So, go to Word and create a new document. Save the document and make a note of its location.
Browse and upload this MS Word Document. Then click OK.
Step 4: Create a Library for Template Customization
While the document template created in the previous step allows for editing, you cannot directly change anything in the metadata fields because it seems MS Word only recognizes the fields from the library (that contains the document).
I am not sure why exactly this was designed like this or if it is a bug or an error on my part, but I have always had to add/map the fields/metadata to MS Word from within the Document Library (vs. from the actual Content Type itself (above)), and then use that updated document as the ‘template’ to replace the template in the Content Type. Hope that makes sense..)
Hence a document library needs to be created, which will use the newly created content type. Thereafter, we will modify the template, map the new metadata/fields, and then the content type template needs to be replaced with this ‘updated’ document.
So, first you need to add a new document library to the site, I just used the default “Documents” library for my example here.
Second, go to the new library then select Library Tab -> Library Settings – > Advanced Settings. Here, choose the Yes option in “Allow management of content types”.
You should see this screen below, select Yes as I highlighted below:
Then Click “Add from existing content types”, you should then see the “Add Content Type” screen, I changed to only show my Acme Corp – Content Types, the screen below:
Add your content type by selecting it and clicking Add. Then Click OK.
We should now see the new Expense Report Content Type in our Library.
I clicked “Change new button order and default content type” to remove the default “Document” content type option, so that users will only be allowed to create “Expense Reports” in this library.
Step 5: Create a new Document in the Library
Once you have removed the default Document, you need to create a new document that will be associated with the content type in the library.
This is where the real magic happens and you can MAP metadata to inside fields in the MS Word file. We will overwrite the template with this new file. Then later, I will show you how you can update multiple MS Word files at once by updating the SharePoint Column values in Quick Edit/Datasheet view!
In the Document Library, click Files (or “Documents” in older versions of SharePoint) -> New Document and choose “Expense Report” (or whatever you called your Content Type)
This will open a new Document, called “Document1.docx”.
It will have the same content as the Content Type template we used. From here, however, we will map the fields.
Save this document, note the location as we need to upload it shortly.
Be sure to keep a backup copy of your template file. Also, be cautious about updates to this template file and that it will not automatically update existing files in your Document Libraries.
Step 6: Replace the Existing Content Type Template
Now that the formatted “Expense Report” template is created, you need to replace the originally created content type template (which did not have the field mapping) with this new one.
So, go back to Site Content Gallery -> Site Settings -> Site Content Types. Select “Expense Report” template.
Now, click on Advanced Settings and replace the existing template with the new one by uploading it from your file system.
Click OK, then go back to “Advanced Settings” and you can now click “Edit Template”
This completes your creation of new content type and using it as template for your documents. Users can create a new library to test it, change the metadata values in the document and save it to see the effectiveness of the overall process.
Step 7: Bulk Updating Content in multiple MS Word documents by using mapped SharePoint metadata
If we have multiple “Expense Reports” for example, I could use datasheet view, also called “Quick Edit”
I’ll open up one of these files that I want to update, let’s say “Expense Report – Copy (2)”
Now, I’ll go back to my Library, and click “Library->Quick Edit”
I’ve quickly added some arbitrary data here:
Notice the values highlighted. That was a quick edit!
Now, if I open up the document, the values inside the file(s) are automatically set! Wow that’s pretty cool!
Again, be cautious of updates and make sure you have backups. I have experienced sometimes files can get corrupted when they get complex, MS Word essentially is made up of xml data it seems which if there are errors, it does not like it..
Another ‘shorter’ way to do this all, is to skip the use of the Content Type and just modify the Document Library template used.
Creating a new content type and adding it to library gives users the flexibility to change content types at the root level, so you can use the content type in multiple libraries and just update it once from the root site ‘Content Types’ gallery section.
Hope you found this useful!
Currently working at Cognillo (https://www.cognillo.com), he has helped architect and develop SharePoint Enterprise products for customers such as the U.S. Navy, U.S. Army, U.N. Security Council of Netherlands, Australian Government, U.S. Dept of Treasury, U.S. Dept of Justice, Canadian Dept of Defense, Scotiabank, JPMorgan CHASE Bank, Intel, Ford Motors, Microsoft, NASA, DARPA, SNC Lavalin, Penguin Books, and more.
He is a proud father of 2, and when he has any spare time, he loves to paint portraits of his kids.
Latest posts by Chris Ang (see all)
- What is SharePoint? A Beginner’s Guide to MS SharePoint Software - October 8, 2018
- Beginner’s Guide: Windows PowerShell – How to Use Tutorial for Dummies - October 8, 2018
- Remote PowerShell to Manage SharePoint on-premises - August 14, 2018