Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Listing the Settings in a Template.

Listing the Settings in a Template

Written by Allen Wyatt (last updated September 7, 2022)
This tip applies to Word 2007, 2010, 2013, and 2016


1

Andy wonders if there is any way to 'list' the settings in a template (margins, fonts, tab stops, etc.). He has seen lots of information about resetting to defaults, but nothing that will tell him what the settings actually are. He notes that opening a template and looking at the various items is clunky and less than comprehensive.

Unfortunately, there is no easy way to do this in Word. The primary reason is because there is no full list of what settings are stored in templates, and the sheer number of such settings can be quite daunting. The best you can do is to create a macro that will examine the settings you are interested in and then display those.

As an example, consider the following suite of macros:

Sub TemplateSettings()
    Dim templatePath As String
    Dim fleName As String
    Dim str As String
    Dim sTemp As String

    ' Select the template to be opened
    templatePath = Application.Templates(1).Path
    fleName = GetTemplateName(templatePath)
    If fleName = "" Then
        MsgBox "No template selected"
        Exit Sub
    End If

    Application.Documents.Open (fleName)

    str = ActiveDocument.Name & vbCr & vbCr

    sTemp = "Other"
    Select Case ActiveDocument.Sections(1).PageSetup.PaperSize
        Case wdPaperLetter
            sTemp = "Letter"
        Case wdPaperLegal
            sTemp = "Legal"
        Case wdPaperA4
            sTemp = "A4"
    End Select
    str = str & "Paper size: " & sTemp

    sTemp = "Landscape"
    If ActiveDocument.Sections(1).PageSetup.Orientation = wdOrientPortrait Then
        sTemp = "Portrait"
    End If
    str = str & "  Orientation: " & sTemp & vbCr

    str = str & "Margins " & marginsStr & vbCr
    str = str & vbCr & "User Defined Tab stops " & UserTabStops & vbCr
    str = str & vbCr & "User defined styles " & userStyles

    Application.Documents(fleName).Close SaveChanges:=wdDoNotSaveChanges

    MsgBox str
End Sub
Function GetTemplateName(templatePath As String) As String
    Dim dlg As FileDialog
    Set dlg = Application.FileDialog( _
      FileDialogType:=msoFileDialogFilePicker)
    With dlg
        .AllowMultiSelect = False
        .InitialFileName = templatePath
        .Filters.Clear
        .Filters.Add "Templates", "*.dotx; *.dotm"
        .Filters.Add "All files", "*.*"
        .FilterIndex = 1
        .Show
        If .SelectedItems.Count > 0 Then
            GetTemplateName = .SelectedItems(1)
        Else
            GetTemplateName = ""
        End If
    End With
    Set dlg = Nothing
End Function
Function userStyles() As String
    Dim sty As Style
    Dim s As String

    s = ""
    For Each sty In ActiveDocument.Styles
        If Not sty.BuiltIn Then
            s = vbCr & sty.NameLocal & "  " & sty.Description
        End If
    Next sty
    userStyles = s
End Function
Function UserTabStops() As String
    Dim s As String
    Dim tbStop As TabStop
    Dim alg

    alg = Array("Left", "Center", "Right", "Decimal", "Bar", "?", "List")
    s = ""
    For Each tbStop In ActiveDocument.Paragraphs(1).TabStops
        s = s & vbCr & ptConvert(tbStop.Position) & _
          " Alignment: " & alg(tbStop.Alignment)
    Next tbStop
    UserTabStops = s
End Function
Function marginsStr() As String
    With ActiveDocument
        marginsStr = _
          "Left: " & ptConvert(.PageSetup.LeftMargin) & _
          ", Right: " & ptConvert(.PageSetup.RightMargin) & _
          ", Top: " & ptConvert(.PageSetup.TopMargin) & _
          ", Bottom: " & ptConvert(.PageSetup.BottomMargin)
    End With
End Function
Function ptConvert(p As Single) As String
    ptConvert = Format(PointsToInches(p), "###.##")
    ' use the following line if you want dimensions in centimeters
    'ptConvert = Format(PointsToCentimeters(p), "###.##")
End Function

The main macro that you start with is TemplateSettings. This macro, in turn, calls the other functions in the listing. It grabs some of the more common settings within a template (you get to specify the template, of course) and then displays those settings in a message box. Specifically, it displays the template's name, paper size, page orientation, margins, tab stops (for only the first paragraph in the template), and user-defined styles.

There are obviously many, many other settings that could be extracted and displayed. For instance, you might want to know what the characteristics of each style are, rather than just a list of user-defined style names. Or you might want to know how formatting for built-in styles differs from default formatting. Just these options alone would introduce a huge amount of complexity to the macro. (Consider that each style can have dozens of different formatting settings and "default formatting" for built-in styles is defined by what is stored in the Normal template.) In order to include such additions, you'd only need to modify the macro to gather and compile the desired information.

Note, as well, that the macro suite presented here is designed to be simple, despite its length. All it does is put all the extracted settings into a string and then display that string in a message box. If the template you are looking at has many, many user-defined styles, then it is possible for the string to get quite long. If it ends up getting too long, then you'll get an error because the MsgBox function can only display a relatively short message. If you anticipate that your string will be longer, you'll want to display it in "chunks" in multiple message boxes, or simply write the string out to a text file that you can later examine.

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 (10118) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Listing the Settings in a Template.

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

Controlling Where a Full-page Border is Printed

When you add full-page borders to your document, you may be bothered to find out that one or more sides of the border ...

Discover More

Splitting Text to Multiple Cells

When processing data, you may have a need to split a long text string into shorter chunks of text consisting of whole ...

Discover More

Canceling a Command

Tired of waiting for a command to finish running? You can use the same shortcut to cancel a command that you use to ...

Discover More

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

More WordTips (ribbon)

Using Documents after a Server Move

Word documents can be interrelated with each other, particularly when you are dealing with templates. Move the templates ...

Discover More

Creating a Boilerplate Document

If you have several boilerplate documents you need to routinely use in Word, then you should learn how to use templates. ...

Discover More

Creating a Document Based on a Template

Double-click a Word template file in Windows, and Word should create a brand new document based on that template. If this ...

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 2 + 2?

2017-06-10 15:36:11

Lee Batchelor

It would be so handy if MS would provide a list of template properties that we can edit instead of drilling through all those menus and sub-menus - something that superior developers achieve for their users. I believe the way of the future will be software that limits menu drilling and excessive scrolling in applications.
Thanks for posting those macros!


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.