Create a Template that Stops Styles from Being Added to a Document

by Allen Wyatt
(last updated February 12, 2014)

4

Dianne wonders if there is a way to create a template that will exclude any new styles from being introduced. Clients paste material with formatting and styles into her documents, and that can cause problems. She wants to build a generic template that will create a document that will lock out non-template styles.

This problem has been one that has plagued Word users for years (if not decades). You can spend quite a bit of time getting your template and style sheet just the way you want it, then send it off to someone else only to have it return with the style list (and document formatting) in the electronic equivalent of tatters.

There are several approaches you can take to attempt to remedy the situation. First, you can try the "please don't do that" approach where you simply ask the others to not paste anything into your document. Or, if they must paste something, ask them to use one of the Paste Special variants that allow pasting without formatting.

If you want a more forceful approach, follow these steps:

  1. Set up your template (including styles) as you desire.
  2. With the template loaded in Word, display the Home tab of the ribbon.
  3. Click the small icon at the bottom-right of the Styles group. Word displays the Styles pane at the right side of your screen.
  4. At the bottom of the Styles pane, click the Manage Styles icon. (If you can't figure out which icon is which, hover the mouse pointer over each icon, in turn, until you see the ToolTip "Manage Styles.") Word displays the Manage Styles dialog box.
  5. Make sure the Restrict tab is selected. (See Figure 1.)
  6. Figure 1. The Restrict tab of the Manage Styles dialog box.

  7. From the styles listed in the dialog box, create a selection set of those styles you want the user to use. (Create the selection set by clicking a style name and then holding down the Ctrl key as you click on other style names.)
  8. Click the Limit Formatting to Permitted Styles check box.
  9. Click OK.
  10. Save your template.

Theoretically, any document based on the template will restrict what styles the user can use in their formatting. What is unclear is whether this also extends to limiting what styles can be pasted into the document. If you prefer a macro-enforced version of this approach you can use the macros detailed at the following blog:

http://blogs.msdn.com/b/ericwhite/archive/2010/01/27/programmatically-limiting-styles-in-word.aspx

Of course you could create a set of macros that would stop people from pasting formatted text into a document. (Place the macros in the template on which the document is based and they are passed to the document automatically. Normal caveat: If the user doesn't enable macros, then this approach is of almost no value.)

For example, one approach is to prevent new styles from being added is to determine the number of styles before and after the paste. If the number has increased, then your macro can undo the paste and give the user the options to either paste the Clipboard as plain text or cancel. This method will also prevent styles being introduced from tables and textboxes.

It is important to realize that there is no "general" paste event that can be trapped in VBA. Instead it is necessary to customize several of Word's built-in commands. The following replace four of those commands.

Sub EditPaste()
    Dim k As Long

    Options.PasteFormatBetweenDocuments = wdMatchDestinationFormatting
    Options.PasteFormatBetweenStyledDocuments = wdUseDestinationStyles
    k = ActiveDocument.Styles.Count
    Selection.Range.Paste
    If k <> ActiveDocument.Styles.Count Then
        ActiveDocument.Undo
        MsgBox "Paste unsuccessful. You tried to introduce new styles."
    End If
End Sub
Sub EditPasteSpecial()
    Dim k As Long
    Dim lk As Boolean

    Options.PasteFormatBetweenDocuments = wdMatchDestinationFormatting
    Options.PasteFormatBetweenStyledDocuments = wdUseDestinationStyles
    k = ActiveDocument.Styles.Count
    With Dialogs(wdDialogEditPasteSpecial)
        .Show
        lk = .link
    End With
    If lk Then
        ActiveDocument.Undo
        MsgBox "You are not allowed to paste links"
        Exit Sub
    End If
    If k <> ActiveDocument.Styles.Count Then
        ActiveDocument.Undo
        If MsgBox("You have tried to introduce new styles." & vbCrLf & _
          "Do you want to paste as plain text?", vbYesNo) = vbYes Then _
          Selection.Range.PasteSpecial datatype:=wdPasteText
    End If
End Sub
Sub PasteDestinationFormatting()
    Dim k As Long

    k = ActiveDocument.Styles.Count
    Selection.Range.Paste
    If k <> ActiveDocument.Styles.Count Then
        ActiveDocument.Undo
        MsgBox "Paste unsuccessful. You tried to introduce new styles."
    End If
End Sub
Sub PasteSourceFormatting()
    MsgBox "You are not allowed to paste with source formatting"
End Sub

Another non-macro approach is to change the protection for the document. With the template loaded into Word, follow these steps:

  1. Display the Developer tab of the ribbon.
  2. Click the Restrict Editing tool in the Protect group. Word displays the Resrict Editing pane at the right side of your document.
  3. In the Formatting Restrictions area, select the Limit Formatting to a Selection of Styles check box.
  4. Click the Settings link, right under the check box. Word displays the Formatting Restrictions dialog box. (See Figure 2.)
  5. Figure 2. The Formatting Restrictions dialog box.

  6. Make sure in that the list of styles reflects those that you want the user able to use.
  7. Adjust the check boxes at the bottom of the dialog box, as desired.
  8. Click OK. Word closes the Formatting Restrictions dialog box.
  9. If the restrictions you put in place raised some potential conflicts with styles used in the document, Word asks you what you want to do. (Answer as you desire.)
  10. Click Yes, Start Enforcing Protection. Word displays the Start Enforcing Protection dialog box.
  11. Enter a password for the protection, if desired. (You'll need to enter it twice.)
  12. Click OK.
  13. Close the Restrict Formatting and Editing task pane.
  14. Save your 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 (12698) 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

Transposing Two Characters

If you have two characters in the wrong order, you might be interested in a shortcut you can use to switch their order. There ...

Discover More

Understanding Underlines

Excel provides a variety of underlining styles you can use when you need to underline information within a cell. Here's what ...

Discover More

Removing Formatting

Need to quickly remove formatting from a selection of text in your document? The Clear Formatting tool makes the task quick ...

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)

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

Understanding Templates

Templates are used to store a pattern for how a document should look. As such, they can be a very powerful tool for creating ...

Discover More

Batch Template Changes

Changing the template associated with a couple of documents is easy, but what if a whole directory needs to be changed? These ...

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 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 4 + 1?

2015-07-19 02:17:27

Lana

Hi Allen

I have been using 'Limit formatting to permitted styles' for a quite some time when I design templates. The only issue I have is that Section Breaks cannot be added therefore you can't switch from portrait to landscape.

Wondered if you knew of a workaround for this. My main issue with unprotected templates is in the multi-authoring environment and people are pasting from external sources. I have deselected 'Keep track of formatting' in Word Options > Editing Options but pseudo styles still appear in the styles pane in the documents.

Many thanks & regards


2013-11-04 11:28:11

Debbie Cipolla

I was charged with the task of over hauling a user manual in which multiple people would be involved. I restricted not only the styles that could be used but also restricted who could make edits and to which areas.

I would like the editors to be able to insert a text box and then be able to insert a picture, etc. I have not been able to accomplish this. If anyone has feedback regarding which style I need to choose in protection mode, I would appreciate it.

Thanks!


2013-11-04 08:52:24

Jennifer Thomas

You could also consider enabling the 'Automatically update document Styles' option to the attached template to address the situation where people add an allowed style name but the source style has different formatting.


2013-11-02 07:40:55

Lee Batchelor

What a wonderful tip. For years, I've had the same problem with Word. When a client sends me amendments to my document, it always comes back in ruins.
There are several issues with Word that MS refuses to either acknowledge or fix. I would love to see a Word Tip that addresses this topic! My answer is simple: there's no profit in fixing a company's blunders.
Keep up the great work! Thanks.
Lee


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.