Toggle Hidden Text w/o Using Menus & Show/Hide

R

rray

I'm trying to write a simple macro that will function as a toggle switch to
turn the display of the hidden text either on or off - I do not want to use
the Tools...Options...View menu to turn off/on hidden text, then use the
Show/Hide button to turn the hiden text on and off. The macro I have managed
to write to date does nothing more than check or uncheck the box in the
Tools...Options...View menu, but has no apparent effect on the document
itself. I can figure out how to change the attributes of the text, but I
don't want to do that - I only want to change whether or not the text is
displayed. I'm stumped. Any ideas?
 
R

rray

Discovered the answer myself. I'm just a beginner, so I don't imagine that
this is an especially elegant solution, but it seems to work

Selection.HomeKey Unit:=wdStory
With ActiveWindow.View
If .ShowAll = True Then
.ShowAll = False
.ShowHiddenText = Not .ShowHiddenText
.ShowTabs = True
.ShowSpaces = True
.ShowParagraphs = True
.ShowOptionalBreaks = True
Else: .ShowHiddenText = Not .ShowHiddenText
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top