Written by Allen Wyatt (last updated August 19, 2023)
This tip applies to Word 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365
Harwood works for a small town as a building inspector. They need to transform our operations to digital, and the State Library requires that any documents created in programs such as Word include metadata. The problem is that it takes extra time to access the document properties and fill in the required information. The only field that populates automatically is the Author name. Harwood wonders if there is a way to automatically set other document properties, such as file name.
Metadata, as Harwood is discovering, is specified in a Word document through the use of document properties. Word includes some basic document properties you can set and it includes document properties that are set automatically as you work with a document.
You can see both the basic and automatic document properties (and change some of the them) by clicking the File tab of the ribbon and then clicking Info at the left side of the screen. Word displays a whole bunch of information about your document, and at the right side you can see, under the Properties heading, some of the basic document properties that can be changed—such as Title, Tags, and Comments—and some of the automatic ones—such as Words, Total Editing Time, Created, and Last Modified.
If you want to change some of the properties, just click on them and type away. If you want to see more properties, then you can click on the down-arrow at the right of the Properties title and choosing Advanced Properties. Word displays the Properties dialog box. Using the controls in the dialog box you can view and make changes to the properties as desired. (Well, you can make changes to the non-automatic document properties.) You can even define custom document properties to be stored with your document. You can learn how to define custom document properties by referring to this WordTip:
https://tips.net/T12599
If you want more information about document properties directly from Microsoft, this page on their website is helpful:
https://support.microsoft.com/en-gb/office/21d604c2-481e-4379-8e54-1dd4622c6b75
Of course, none of this helps Harwood that much. The reason is that setting the basic document properties or defining custom document properties can be quite labor intensive. You can try setting document properties in a template and then basing new documents on that template, but that doesn't change the need to still massage those properties in the new document.
The only way that I've been able to discover how to remove some of the tedium from setting document properties is to rely on a macro to do the work for me. For instance, the following is a pair of simple macros that create two custom document properties and sets their values:
Sub SetTwoProps()
Dim sTemp As String
Dim sMsg As String
sMsg = "Results of Setting Properties:" & vbCrLf
sTemp = " State File Number was"
If SetProp("StateFileNum", "X23TR7-001") Then
sTemp = sTemp & " set"
Else
sTemp = sTemp & " NOT set"
End If
sMsg = sMsg & sTemp & vbCrLf
sTemp = " Document Filing Date was"
If SetProp("DocFileDate", Format(Date, "dd Mmmm YYYY")) Then
sTemp = sTemp & " set"
Else
sTemp = sTemp & " NOT set"
End If
sMsg = sMsg & sTemp
MsgBox sMsg
End Sub
Function SetProp(sPropName As String, sPropValue As String) As Boolean
Dim bExists As Boolean
Dim vItem As Variant
SetProp = False
On Error GoTo ExitFunc
' See if document properties already exist
bExists = False
For Each vItem In ActiveDocument.CustomDocumentProperties
If vItem.Name = sPropName Then
bExists = True
Exit For
End If
Next vItem
' Create document property if it doesn't exist
' If it does exist, just set its value
If Not bExists Then
ActiveDocument.CustomDocumentProperties.Add _
Name:=sPropName, LinkToContent:=False, _
Type:=msoPropertyTypeString, Value:=sPropValue
Else
ActiveDocument.CustomDocumentProperties(sPropName) = _
sPropValue
End If
' Made it through successfully
SetProp = True
ExitFunc:
End Function
To use these macros, you run the SetTwoProps macro to specify the property names, the values, and to display a results message (put together in the sMsg variable). The macro calls the SetProp function, which actually does the "heavy lifting" of setting the document property. It checks to see if the property already exists and, if it doesn't, it creates the property. It returns True or False, depending on whether the property setting was successful or not.
Harwood could use a macro similar to SetTwoProps to set the document properties necessary to satisfy the State Library. When you first create a document (or before you send the document off to the State Library) you could then run the macro to make sure the document properties are set the way they need to be set.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (11418) applies to Microsoft Word 2010, 2013, 2016, 2019, 2021, and Word in Microsoft 365.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!
What are you to do if you embed fonts in a document and then someone else cannot make changes to that document? Chances ...
Discover MoreWhen you save a file, the information from the start of the file is saved in the properties for the document and can be ...
Discover MoreWord maintains a collection of descriptive properties for each document you create. One of these properties is the Title ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments