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

Written by Allen Wyatt (last updated July 13, 2019)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


9

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. 7 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 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 to the Clipboard as plain text or cancel. This method will also prevent styles from 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 Restrict 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 that the list of styles reflects those that you want the user to be 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.

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 (12698) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

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

Overlining Characters

Want to add an overline above a character or two in your document? There are several ways you can try, as described in ...

Discover More

Extracting URLs from Hyperlinked Images

When copying information from the Internet to an Excel workbook, you may want to get rid of graphics but keep any ...

Discover More

Disabling Shift Key Use when Opening a Workbook

Open up a workbook, and Excel normally runs the macros associated with that workbook. You can disable the automatic ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Where is the Normal Template Stored?

The Normal template is used all the time in Word. If you want to figure out where the template is stored on your system, ...

Discover More

Examining Styles and Macros in a Template

Templates are very powerful with the ability to contain both styles and macros. If you want to see what styles and macros ...

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
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 two less than 9?

2024-02-19 13:13:10

Tomek

@Robert S Eisenberg and @Robert Eisenberg (if you are two different people):

Whether you like styles or not, even if you think you don't use them in the original document, you still have to use at least one style, probably Normal. Certain things like numbered and bulleted lists, or numbered headings, or endnotes and footnotes, or captions also automatically impose additional styles. So you cannot really avoid them.

Even with everything being originally only in Normal style, the document may come back with modified/added styles.

At my work, I created templates with styles and other elements (e.g, the title page, TOC, and references) to be used by specific teams, but I conducted training/demonstration on how to properly use them. Although I never forced team members to use the templates or the styles, we had specific requirements on how specific documents looked like, for example technical reports, minutes of meetings, etc. Proper templates made adhering to these requirements much easier, but if someone wanted to create a document with just manual formatting they could do that. They had to adhere strictly to the particular document format and style requirements.


2024-02-19 12:58:44

Tomek

Just a thought:
Rather than trying to restrict editing by other people, may be one can use track changes. Then when the document comes back, quickly go through it focusing on formatting changes and rejecting/restoring original styles. There may be two options for this: turning on track changes (which can be turned off by others) or running document comparison when it comes back.


2024-02-19 02:07:29

GFIN Sunny

Thanks, how to quickly Style Replace based on string as shortcut?
Example is emphasize content such as "Hour and Minutes" and Action and de-emphasize remaining Contents of output from Windows Steps Recorder.


2020-01-13 05:33:04

Cadillac1206

How to initiate the paste macro after we paste data?


2019-09-06 10:38:19

Paul Stregevsky

When I distribute a template for a proposal team, I sometimes select "Limit formatting to permitted styles". But if you do so, two caveats:

1. Provide an ample selection of character styles, or users will be pissed off when they can't legitimately apply superscript, subscript, small caps, bold italic, or another attribute that, for whatever reason, needs to be applied.
2. Users won't be free to tweak a table structure in certain ways. For example, they won't be able to change the cell padding to fit that a 1.1-page table onto a single page. If I recall correctly, they won't be able to straddle (merge) rows or columns, either.


2019-09-06 03:55:19

Robert S Eisenberg

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

This most helpful tip shows, I am sorry to say, exactly why I find Styles to be a serious impediment to efficient work.


As you say
"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."

This is one example of a general problem. Styles become corrupted. It is so much trouble keeping them in a defined state, that I find it better
to abandon them altogether.

This confusion combines with an appalling interface (because it is the concatenation of many different attempts to simplify the interface) that
Styles seems to me one of Microsoft Words epic disasters!

I hope you will be willing to publish this Comment, however much you disagree with it.


2019-09-05 06:28:58

David

We have a common issue which occurs when we send documents to people in other physical locations (e.g. other offices around the world) for editing & review (with comments).

The issue is that when the document is sent back to us, following editing elsewhere, it is pretty messed up. Styles have changed, the document generally looks different. I understand this could be because they have different templates/printer settings etc. on their local machine. So, when they open the document it messes things up.

Would the approach listed on this thread help to negate this issue? Essentially, we want to allow other people to edit the documents, but have confidence that the document will come back looking as it did, just with different content/added comments.

Yes, I know Word isn't the optimum solution and email transfer is far from ideal. Currently looking at hosting the documents on a SharePoint site.

Any advice would be appreciated. This is a long-term issue which we've been seeking a resolution to.


2019-07-16 02:50:00

Robert Eisenberg

This kind of arbitrary nonsense is why most users do not use Styles at all.


2019-07-14 08:28:32

Srimitha

Yes it worked for me. Thanks for the information


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.