Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Clearing the Undo Stack in a Macro.
by Allen Wyatt
(last updated October 11, 2014)
Normally, as you are making edits in your documents, Word keeps track of what you do. Word does this so you can later use the Undo and Redo commands on the toolbar. What if you are developing a macro, however, and you don't want the user to be able to undo changes? In this case, you can use the UndoClear method in your macro, as follows:
In this usage, UndoClear wipes out the Undo stack (the list of actions that is remembered by Word) for the active document. Note that this affects only those actions that have been recorded so far; any new actions will be duly recorded and available on the stack.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13275) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Clearing the Undo Stack in a Macro.
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!
Need to run one macro from within another macro? You can easily do it by using the Run method of the Application object, as ...Discover More
One of the powerful programming structures provided in VBA allows you to conditionally execute commands. The If ... End If ...Discover More
If you are working with dates in a macro, you may need to determine which week of the year a date falls within. This can be ...Discover More
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.