This page explains how to create “smart” documents templates in Microsoft Word, using quick parts, to display document metadata from SharePoint inside the actual document, e.g. the page header/footer, e.g:
To add an embedded metadata, follow these steps:
- Add the site columns that should be added as metadata, to the document template library (see instructions here).
- Open a Word document from the document templates library.
- Place the marker in the document where you want to add the quick part.
- Select the “Insert” tab in Word and, in the “Text” section, then “Quick Parts” and depending on which metadata you want to add, you either select “Document Property” (for all custom columns and certain word properties) or “Field” (for certain standard SharePoint columns):
In the section “Standard SharePoint columns as embedded Metadata” bellow, you will see which quick parts to choose, for standard SharePoint columns. - Select the appropriate quick part.
- If needed, format the inserted quick part (font, font size, font color, etc.).
- Save and close the document.
- New documents that are created from the template will now contain the Quick Part (metadata).
Standard document properties as embedded metadata
These standard document properties can be added as embedded metadata:
- Name
- “Name” is the document’s name, including its file-extension.
- Can be added as an embedded metadata in documents, by inserting the “FileName” Field Quick Part.
- Unfortunately this field does not automatically update when you open a document. Here you find instructions on how to make this field updated, manually or automatically.
- Created
- Can be added as an embedded metadata in documents, by inserting the “CreateDate” Field Quick Part.
- Unfortunately this field does not automatically update when you open a document. Here you find instructions on how to make this field updated, manually or automatically.
- Author
- Can be added as an embedded metadata in documents, by inserting the “Author” Field Quick Part.
- Modified
- Can be added as an embedded metadata in documents, by inserting the “SaveDate” Field Quick Part.
- Modified by
- Can be added as an embedded metadata in documents, by inserting the “LastSavedBy” Field Quick Part.
- Unfortunately this field does not automatically update when you open a document. Here you find instructions on how to make this field updated, manually or automatically.
- Title
- “Title” is a regular document column that users can update, if the column is available in the documents’ content type, as mandatory or optional.
- It can be added as an embedded metadata in documents, by inserting the “Title” Document Property Quick Part.
- This column is synchronized with the documents’ “Title” property.
- Document ID
- Can be added as an embedded metadata in documents, by inserting the “Document ID Value” Document Property Quick Part (only shown if you have activated the “Document ID Services” feature).
Document version number as an embedded metadata
Unfortunately there’s no easy and foolproof way to show a document’s version number as an embedded metadata inside a document. It is however possible to create a custom flow that does this but it requires some development effort which could be offered by MetaShare’s development team.
Other Document Property Quick Parts that can be used as embedded metadata
Apart from the file properties mentioned above, other file properties can also be added as Document Property Quick Parts. Some of these can be set, from Microsoft Word, by clicking on the document’s “File” tab, selecting “Info”. The properties are located under the “Properties” section:
These properties plus a few more, can also be set and updated from within Word, by first adding them as Document Property Quick Parts and then updating their values:
Quick Part’s name | Available as File property? |
Abstract | |
Author | Yes |
Category | Yes, as “Categories” |
Comments | Yes |
Company | Yes |
Company address | |
Company E-mail | |
Company Fax | |
Company Phone | |
Keywords | Yes, as “Tags” |
Manager | Yes |
Publish Date | |
Status | |
Status | Yes |
Subject | Yes |
How to update fields in Word
Unfortunately some embedded “Document Property” fields, e.g. “Name”, are not automatically updated when you open a Word document. The field will however automatically be updated when you switch to print preview, if “Update fields before printing” in Word Options is set to yes:
If you want to manually update a field in the document, just select the field and then press F9 on your keyboard.
You can otherwise create a Word Macro that does this automatically for you when you open any document, the disadvantage of this is that all documents will be modified, when you open a document and you will be asked if you want to save your changes when you close the document even if it is only opened in read-only mode. To do this you have to:
- Click on Word’s “Developer tab”, and then click “Macros” in the “Code” group.
- In the Macros dialog box’s “Macro name” field, type: AutoOpen.
- To make the Macro run on all documents that you open in Word, select to store the macro in “All active templates and documents” in the “Macros in” field.
- Click the “Create” button.
- In the code sheet of the Microsoft Visual Basic editor, you should now see the beginnings of your AutoOpen macro. It will look like this:
Sub AutoOpen() ' ' AutoOpen Macro End Sub
- Copy and paste, the following macro code into your AutoOpen macro, before the last line:
Dim aStory As Range
Dim aField As Field
For Each aStory In ActiveDocument.StoryRanges
For Each aField In aStory.Fields
aField.Update
Next aField
Next aStory
- Your AutoOpen macro should now look something similar to the this:
- On the File menu and click on “Save”.
Discover MetaShare
Metadata-centric document management system in Microsoft 365/SharePoint
- Eliminates annoying gaps in standard SharePoint
- Ensures data in SharePoint is well structured
- Structures with metadata instead of storing in traditional folders
- Centralized and simplified administration
- Orchestration/provisioning of settings
- Refined Enterprise search