Examining Styles and Macros in a Template

 

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.

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)

Changing the Attached Template

Templates, when attached to a document, can greatly affect how that document looks. You can change from one template to ...

Discover More

Opening a Template

If you have a template stored on disk, you can open it and make changes to it just as you do other documents. This tip ...

Discover More

Tracking Changes to Templates

Wouldn't it be great to be able to track what changes are made to a template, over time? Unfortunately, Word doesn't include ...

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 for this tip:

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. 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 8 - 1?

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?


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.

Links and Sharing
Share