Changing Lots of Title Properties

Written by Allen Wyatt (last updated December 27, 2022)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


2

Rachel has several hundred documents in which she needs to change the title property. (This is the title property maintained with the other document properties.) She wonders if there is a way to easily make this change in such a large number of documents.

Word doesn't have a built-in way to affect a large number of documents at the same time, but you can create a macro to do the work for you. The important thing to remember is that you want to be able to access the built-in document Title property, and you do that in VBA by fiddling with the BuiltInDocumentProperties collection. For instance, you can change the Title property in VBA in this manner:

ActiveDocument.BuiltInDocumentProperties("Title") = "xyz"

To make your macro effective for a large number of documents, all you'd need to do is to determine the names of the documents you want to affect, load each document in turn, change the Title property, and then save the document. The following macro accomplishes this set of tasks:

Sub ChangeTitles()
    Dim Directory As String
    Dim FType As String
    Dim FName As String
    Dim sTitle As String
    Dim sFiles(250) As String
    Dim iFiles As Integer
    Dim J As Integer

    Directory = Environ("USERPROFILE") & "\Desktop\temp\"
    FType = "*.docx"
    sTitle = "My New Doc Title"

    ' Get names of documents
    iFiles = 0
    FName = Dir(Directory & FType)
    While FName <> ""
        iFiles = iFiles + 1
        sFiles(iFiles) = FName
        FName = Dir
    Wend

    ' Process files
    For J = 1 To iFiles
        Documents.Open FileName:=Directory & sFiles(J)
        ActiveDocument.BuiltInDocumentProperties("Title") = sTitle
        ActiveDocument.Close wdSaveChanges
    Next J
End Sub

Note that near the beginning of the macro the Directory variable is set equal to the full path to the "temp" folder on the desktop. You should make sure that Directory is set to the full path to wherever you have the documents you want to change. Note, as well, that the path ends with a backslash—this is very important.

The other variable you'll want to change is the new title that you store in the sTitle variable. Every document in the Directory folder will have its Title property changed to whatever is stored in the sTitle variable.

The first part of the macro steps through all the files in the target directory and grabs the name of any DOCX file there. These are stored in the sFiles array. Once this is complete, then the array is stepped through and used as a guide for the files to be opened and changed.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the WordTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13543) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Word and Character Count Information

Using fields you can easily insert both the word and character counts for a document into the document itself. Here's how ...

Discover More

Pulling a Phone Number with a Known First and Last Name

When using an Excel worksheet to store data (such as names and phone numbers), you may need a way to easily look up a ...

Discover More

Changing Text Case Many Times

Word provides a built-in shortcut to change the case of a text selection. Understanding how that shortcut works (and the ...

Discover More

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 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!

More WordTips (ribbon)

Embedding Your Phone Number in a Document

One way you can designate your responsibility for a document is to add your phone number to it. There is no need to add ...

Discover More

Blocking the First Sentence from File Info

When you save a file, the information from the start of the file is saved in the properties for the document and can be ...

Discover More

Controlling Document Properties

Word keeps track of quite a bit of document-related information that it refers to as "properties." Here's how to control ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 7?

2018-07-02 09:41:15

Jennifer Thomas

I'm a bit confused by the goal itself, although this looks like it accomplish the process by changing every title in the directory to the same new title. But would Windows would add the (1) (2) automatically or would it would keep prompting 'Do you want to replace the existing file"?

When I've used external software for an issue like this I usually want to add a prefix or some other common element to the all titles - can anyone suggest a variation that would do that?

I always prefer to use VBA than risking the use of 'freeware' (and free spyware to go with it), so thanks in advance!


2018-07-02 04:28:41

Patrick Verhaeghe

One can always change that property trough Windows Explorer.
Select the files rightclick - Properties - Details - Title.
Works with .doc & .docxfiles at the same time
(see Figure 1 below)


Figure 1. 




This Site

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.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.