Toggling Toolbar button

J

John

I've written some VBA code to toggle text boundaries in Word, and have
assigned a toolbar button to this. At the moment, the toolbar button
looks the same when text boundaries are on or off. Is there a way to
make the toolbar botton appear to be depressed when I click it to turn
text boundaries on, and to appear as normal when I click it again to
turn text boundaries off? The Bold toolbar button works like this.
 
T

Tonya Marshall

John said:
I've written some VBA code to toggle text boundaries in Word, and have
assigned a toolbar button to this. At the moment, the toolbar button
looks the same when text boundaries are on or off. Is there a way to
make the toolbar botton appear to be depressed when I click it to turn
text boundaries on, and to appear as normal when I click it again to
turn text boundaries off? The Bold toolbar button works like this.
I believe Doug Robbins wrote this macro for me:

Sub TextBoundaries()
Dim btn As CommandBarButton
Set btn = CommandBars.ActionControl
If ActiveDocument.ActiveWindow.View.ShowTextBoundaries _
= True Then
ActiveDocument.ActiveWindow.View.ShowTextBoundaries = False
btn.State = msoButtonUp
Else
ActiveDocument.ActiveWindow.View.ShowTextBoundaries = True
btn.State = msoButtonDown
End If
ThisDocument.Saved = True
End Sub
 
J

Jon

Thanks, that works just fine.

Tonya Marshall said:
I believe Doug Robbins wrote this macro for me:

Sub TextBoundaries()
Dim btn As CommandBarButton
Set btn = CommandBars.ActionControl
If ActiveDocument.ActiveWindow.View.ShowTextBoundaries _
= True Then
ActiveDocument.ActiveWindow.View.ShowTextBoundaries = False
btn.State = msoButtonUp
Else
ActiveDocument.ActiveWindow.View.ShowTextBoundaries = True
btn.State = msoButtonDown
End If
ThisDocument.Saved = True
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