Toggling Hidden Codes and Text

When you choose Home, Show/Hide, Word displays symbols that represent hidden “characters,” such as tabs, spaces, paragraph marks, and optional hyphens, as well as any text formatted as hidden.

This is handy for looking “under the hood” of the document. However, a thorough check of a document’s inner workings should also include other normally hidden items: bookmarks, comments, revisions, and field codes.

You can toggle all of these by hand individually, but if you need to do this often, the procedure in Listing 1.3 is much easier.

Listing 1.3 Toggling Hidden Codes and Text
Public Sub ShowAll()
Dim currentState As Boolean
With ActiveWindow.View
currentState = .ShowBookmarks
.ShowBookmarks = Not currentState
.ShowComments = Not currentState
.ShowFieldCodes = Not currentState
.ShowHiddenText = Not currentState
.ShowHyphens = Not currentState
.ShowOptionalBreaks = Not currentState
.ShowParagraphs = Not currentState
.ShowRevisionsAndComments = Not currentState
.ShowSpaces = Not currentState
.ShowTabs = Not currentState
.Type = wdNormalView
End With
End Sub
The procedure is named ShowAll, which is the internal name of the command that Word runs when you click the Show/Hide button. Therefore, clicking Show/Hide will now run the ShowAll procedure. Using the active window’s View object, the program first checks the current state of the ShowBookmarks property and stores the state in the currentState variable.
Then each of the View properties is set to the opposite value. Figure 1.15 and 1.16 show the two states produced by the procedure.

Add to Technorati Favorites


// Related Posted - GOOGLE!

Loading



Related Websites
Monday, May 19th, 2008 at 14:15
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>