Depressed toggle button

D

Drake

Hey everyone -

okay, except for the fact that the button needs therapy....

I need help with a custom button - I want it to show as depressed when it is
True. Here is my current code. What should I add and where?

Thanks!

--------
Public Sub Show_Hide()
If ActiveDocument.ActiveWindow.View.ShowHiddenText = True Then
ActiveDocument.ActiveWindow.View.ShowHiddenText = False
ElseIf ActiveDocument.ActiveWindow.View.ShowHiddenText = False Then
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
ActiveDocument.ActiveWindow.View.ShowAll = False
End If
End Sub
 
K

Klaus Linke

okay, except for the fact that the button needs therapy....


Hi Drake,

Here's what the doctor orders:

Dim myCBB As CommandBarButton
Set myCBB = CommandBars.ActionControl
With ActiveDocument.ActiveWindow.View
.ShowHiddenText = Not(.ShowHiddenText)
myCBB.State = Not (myCBB.State)
.ShowAll = False
End with

Regards,
Klaus
 
K

Klaus Linke

On second thought, you don't really know which state you're starting with
(hidden text displayed, or not).
So you better keep your original "If ...", and set "myCBB.State =
msoButtonDown"/"myCBB.State = msoButtonUp" as desired.

Klaus
 
J

Jezebel

First, you can replace all of this
If ActiveDocument.ActiveWindow.View.ShowHiddenText = True Then
ActiveDocument.ActiveWindow.View.ShowHiddenText = False
ElseIf ActiveDocument.ActiveWindow.View.ShowHiddenText = False Then
ActiveDocument.ActiveWindow.View.ShowHiddenText = True

with...

With ActiveDocument.ActiveWindow.View
.ShowHiddenText = not .ShowHiddenText
end with

What you haven't explained is where this button is located... on a toolbar?
on a form? on a UserForm?
 

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