Creating Quick Style Sets in Word 2010

Office 2010

Office Quick Note banner

Working with Styles in Microsoft Word: Learn how to create new Quick Style sets in Microsoft Word 2010.

Last modified: May 12, 2011

Applies to: Office 2010 | VBA | Word 2010

In this article
Add a Standard Module to a Word Document
Add the Code to the Visual Basic Editor
Test the Solution
Next Steps

Published:   May 2011

Provided by:    Frank Rice, Microsoft Corporation

Quick Styles and Quick Style sets provide easy access and visibility to styles that you frequently use in a document. Although a Quick Style set most likely contains all of the styles that you must have to build a document, you can add a new style or change some of the styles in a Quick Style set to reflect your style preferences. After you add or change styles, you can save the new style combination as a custom Quick Style set that has a different name. In this topic, you programmatically modify an existing Quick Style set and then save it under a new name so that you can use it in other documents. To complete this task, you must do the following:

In this task, you open a Word 2010 document, open the Visual Basic Editor, and then insert a standard module.

To add a standard module to a Word document

  1. Start Word 2010.

  2. On the Developer tab, click Visual Basic to open the Visual Basic Editor.

    Note Note

    If you do not see the Developer tab in Word 2010, click the File tab, and then click Options. In the categories pane, click Custom Ribbon, select Developer, and then click OK.

  3. On the Insert menu, click Module. This adds Module1 to the Projects pane on the left side of the Visual Basic Editor.

In this task, you add programming code that applies an existing Quick Style set, modifies it, and then saves it under a new name.

To add code to the Visual Basic Editor

  1. In the Projects pane, click Module1.

  2. Paste or type the following Microsoft Visual Basic for Applications (VBA) code into the module window.

    Sub TestQuickStyles()
        ' Word 2010 adds the ability to apply a quick style set. Previously
        ' you could only save a quick style set.
        ' Apply one of the built-in style sets.
        ActiveDocument.ApplyQuickStyleSet2 "Elegant"
        ' Modify the style set:
        With ActiveDocument.Paragraphs(1)
            .LineSpacing = 20
            .LeftIndent = 20
        End With
        ActiveDocument.SaveAsQuickStyleSet "New Style"
        ' Load another style set:
        ActiveDocument.ApplyQuickStyleSet2 "Word 2010"
        ' Re-apply your new style set:
        ActiveDocument.ApplyQuickStyleSet2 "New Style"
    End Sub

In this task, you step through the VBA code and see how various Quick Style sets affect your text.

To step through the code

  1. In the document, type the following command to add five paragraphs of text.


  2. Drag the Visual Basic Editor window to the right side of your monitor.

  3. Drag the Word window to the left side of the monitor and adjust the windows until you can see them both.

  4. Place the cursor in the TestQuickStyles module, and then press F8 to step through the code line-by-line; watch the text change as the code applies the styles.

  5. To verify that the modified style is saved as NewStyle.dotx, open the folder that is specified in the following note. Saving the style set adds it to the available Quick Style sets list and enables you to use it in other documents.

    Note Note

    Quick style sets are stored as .dotx files in the following folder in Windows 7: C:\Users\<userName>\AppData\Roaming\Microsoft\QuickStyles. The location is different in other operating systems, and in customized installations of Office 2010.

  6. Delete files from the QuickStyles folder to remove them from the list of Quick Styles.