Toggle text boundaries

K

Kamran

I would like to create a toolbar button to toggle text boundaries on and off.
I made one just recording actions to turn boundaries on, but I would like to
be able to use the same button to toggle on and off. Thanks.
 
S

Shauna Kelly

Hi Kamran

This macro will toggle the display of text boundaries:

Sub ToggleTextBoundaries()

If Documents.Count > 1 Then
With ActiveWindow.View
.ShowTextBoundaries = Not .ShowTextBoundaries
End With
End If

End Sub


For information on how to use the macro, see
Graham Mayor's Idiots' Guide to Installing Macros
http://www.gmayor.com/installing_macro.htm

For information on how to attach the macto to a button, see
How to assign a Word command or macro to a toolbar or menu
http://www.mvps.org/word/FAQs/Customization/AsgnCmdOrMacroToToolbar.htm


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
K

Kamran

Thanks, Shauna. I assigned the macro to a toolbar button. For some reason
it wouldn't work so I removed the "If - End If" part of it. By using just
the middle part it worked okay. Was there something else I was supposed to
do?
 
K

Kamran

Thanks, Shauna. I assigned the macro to a toolbar button. It wouldn't work
at first, until I removed the "If - End If" part of it. By using just the
middle part it worked great. Was there something else I was supposed to do?
 
S

Stefan Blom

The If statement checks if there are open documents. Change the first line so
that it reads:

If Documents.Count > 0 Then

Now, the macro should work as intended, even if only a single document is
open!

Stefan Blom
 

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