Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Copying Custom Properties.
Written by Allen Wyatt (last updated March 20, 2021)
This tip applies to Word 97, 2000, 2002, and 2003
Custom document properties are a great way to store unique information that is associated with a document. For instance, you may have a company-assigned document number that needs to be stored with a document. A custom property fits the bill quite nicely for this purpose.
As you add custom properties to a document, you may start wondering if there is an easy way to copy them from one document to another. Unfortunately, there is no way to do this. (In my estimation, this capability would make a fine addition to the Organizer.) You can, however, create a macro that will do the copying for you. The following macro will do just that:
Sub CopyDocProps()
Dim dp() As DocumentProperty
Dim CustomPropCount As Integer
Dim i As Integer
Dim intResponse As Integer
If Windows.Count > 2 Then
MsgBox "There are more than two windows. Please " & _
"close the others and re-run the macro.", , _
"Too many windows"
Exit Sub
End If
On Error GoTo Err_Handler
intResponse = MsgBox("Are you currently in the source document?", _
vbYesNoCancel, "Copy Custom Properties")
If intResponse = vbNo Then Application.Run MacroName:="NextWindow"
CustomPropCount = ActiveDocument.CustomDocumentProperties.Count
ReDim dp(1 To CustomPropCount)
For i = 1 To CustomPropCount
Set dp(i) = ActiveDocument.CustomDocumentProperties(i)
Next i
Application.Run MacroName:="NextWindow"
For i = 1 To CustomPropCount
If dp(i).LinkToContent = True Then
ActiveDocument.CustomDocumentProperties.Add _
Name:=dp(i).Name, _
LinkToContent:=True, _
Value:=dp(i).Value, _
Type:=dp(i).Type, _
LinkSource:=dp(i).LinkSource
Else
ActiveDocument.CustomDocumentProperties.Add _
Name:=dp(i).Name, _
LinkToContent:=False, _
Value:=dp(i).Value, _
Type:=dp(i).Type
End If
Next i
MsgBox "The properties have been copied."
Exit Sub
Err_Handler:
' if Word raises an error, then allow the user
' to update the custom document property
intResponse = MsgBox("The custom document property (" & _
dp(i).Name & ") already exists." & vbCrLf & vbCrLf & _
"Do you want to update the value?", vbYesNoCancel, _
"Copy Custom Properties")
Select Case Response
Case vbCancel
End
Case vbYes
ActiveDocument.CustomDocumentProperties(dp(i).Name).Value _
= dp(i).Value
Resume Next
Case vbNo
Resume Next
End Select
End Sub
This code is an example of how to copy custom properties, but it is not bulletproof. For instance, it does not check to see if there are actually any custom properties in the source document; it just assumes that there are. Such coding could be easily added, however.
In order to use the macro, make sure that you have only the source and target documents open, and you should only have one window open per document. When the macro is finished, you will need to save the target document.
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 (1340) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Copying Custom Properties.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2019. Spend more time working and less time trying to figure it all out! Check out Word 2019 For Dummies today!
Read-only documents (those that cannot be updated) are part and parcel of working with Word. There are many ways that a ...
Discover MoreYou can easily place a path and filename in the footer of your document. What do you do if it appears that these elements ...
Discover MoreOver the years Microsoft has made changes in Word. One change is to the import and export filters provided with the ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-01-12 10:49:51
Al Gray
Your Err_Handler has a bug.
<code> Select Case Response <endcode>
should be:
<code> Select Case intResponse <endcode>
2021-09-27 12:25:15
Jules Edwards
Just wanted to let you know the Case Statement Response should be Select Case intResponse - as it is written it always falls through.
2021-09-09 08:53:37
Niels
Intresponse and response variables are not matching! Thanks for the macro
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon 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