Examining Styles and Macros in a Template

by Allen Wyatt
(last updated November 9, 2013)

2

Templates are designed to contain a collection of styles, macros, and other customizations that can be used to help consistently develop a document or series of documents. If you receive a template from someone else (or open one that you created years ago) you may wonder if there is a way to display the details of the styles and macros contained within that template.

There is no built-in way to do this, unfortunately. (It would be very helpful if there was.) Word allows you to relatively easily see which styles are in a template or, for that matter, in a document. All you need to do is load the template and use the Organizer to look at the styles it contains. If you prefer, you could use a macro to list in a new document all the styles in the current one. There are many ways ot approach such a task; the following is one written by Jessica Weissman:

Sub describeAllStylesWeCareAbout()
'  by Jessica Weissman

    Dim docActive As Document
    Dim docNew As Document
    Dim styleLoop As Style

    Set docActive = ActiveDocument
    Set docNew = Documents.Add
    For Each styleLoop In docActive.Styles
        If styleLoop.Type < 3 Then
        ' show only character and paragraph styles, not list or table styles
            With docNew.Range
                .InsertAfter Text:=styleLoop.NameLocal & Chr(9) _
                  & styleLoop.Description
                .InsertParagraphAfter
                .InsertParagraphAfter
            End With
        End If
    Next styleLoop
End Sub

The problem with either approach (Organizer or special macro) is that they don't list any modifications to built-in styles that are often so important to effectively designing a template. For instance, if the Normal style on a system is normally set to 10-point Arial and that has been changed to 12-point Times New Roman in the template, there is no way with the above solutions to tell that this change has been made; you only know that the template uses the Normal style. (Duh! All templates contain the Normal style.)

When it comes to macros, you need to load the template and simply go look in the Visual Basic Editor. There is where you'll find the macros and be able to try to figure out what they do. (Make sure you use the Project window to look for VBA projects specifically associated with the template.)

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

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

Bypassing the BeforeClose Event

Hold down the Shift key as you open a workbook, and Excel bypasses any "startup macros" that may be in the workbook. If you ...

Discover More

Deriving Monthly Median Values

When processing huge amounts of data, it can be a challenge to figure out how to derive the aggregate values you need. This ...

Discover More

Automatic Row Height For Merged Cells with Text Wrap

When you have text wrap turned on in a cell, Excel expands the height of the row as you add more text to the cell. When you ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (ribbon)

Creating a Letterhead Template

Word is often used to write all sorts of letters. You may want to create a template that makes creating your letters easier ...

Discover More

Finding Where Templates Are Stored

The first step in modifying templates is to find out where they are stored on your system. Here's the easiest way to figure ...

Discover More

Recovered Document becomes Default

Word has a feature called AutoRecover that helps you when Word or Windows crashes. If your Normal template gets messed up for ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 5 + 0?

2015-10-07 06:20:12

Torben

To create the same with the name actually formatted in that style, you can do this:

'=============================================================================================
Sub describeAllStylesWeCareAbout()
' by Jessica Weissman
' http://wordribbon.tips.net/T012715_Examining_Styles_and_Macros_in_a_Template.html

Dim docActive As Document
Dim docNew As Document
Dim styleLoop As Style

Set docActive = ActiveDocument
Set docNew = Documents.Add
For Each styleLoop In docActive.Styles

'wdStyleTypeCharacter 2 Body character style.
'wdStyleTypeList 4 List style.
'wdStyleTypeParagraph 1 Paragraph style.
'wdStyleTypeTable 3 Table style.

If styleLoop.Type = wdStyleTypeParagraph Then
Selection.Style = styleLoop
Selection.TypeText Text:=styleLoop.NameLocal
Selection.TypeParagraph
Selection.Style = ActiveDocument.Styles("Normal")
Selection.Font.size = 9
Selection.TypeText Text:=styleLoop.Description
Selection.TypeParagraph
Selection.TypeParagraph
End If
Next styleLoop
End Sub
'=============================================================================================


2013-11-09 10:50:12

bo vandenberg

How about taking us through the solution you suggest? How do you open the editor and load the template?


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.

Newest Tips
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.