Word: Macro to show all formatting on opening a documentJuly 13, 2011
I’ve written before about using a macro to show all formatting marks, bookmarks, table grid lines and field shading before, and just yesterday I gave you a macro for turning off the track formatting option in Track Changes. The problem is that these macros require user input to run.
So what if you find these options pretty clever and want to include them in your template so that every time you opened a document based on that template, they’d automatically run and the author wouldn’t have to remember to run them? For that you need to add them to the AutoOpen() macro.
AutoOpen and AutoNew macros are inbuilt into Word, and anything you include in them is automatically run whenever you open a document (AutoOpen) or create a new document (AutoNew) based on the template.
Here’s how to incorporate the two macros above into an AutoOpen() macro:
Sub AutoOpen() ' macro to display bookmarks, field shading, formatting marks, _ table grid lines and turn off Track Formatting in Track Changes _ on opening an existing document based on the template With ActiveWindow.View .ShowAll = True .ShowBookmarks = True .FieldShading = wdFieldShadingAlways If ActiveDocument.ActiveWindow.View.TableGridlines = False Then ActiveDocument.ActiveWindow.View.TableGridlines = True End If End With With ActiveDocument .TrackFormatting = False End With End Sub
[Links last checked July 2011]