View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default disabling a command button

Manage the caption color yourself.

Sub DisAbleButton()
Dim shpbtn As Shape
Dim bnt As Button
Set btn = ActiveSheet.Buttons("Button 2")
Set shpbtn = ActiveSheet.Shapes("Button 2")
With shpbtn
.ControlFormat.Enabled = False
.TextFrame.Characters( _
Start:=1, Length:=Len(btn.Caption)) _
.Font.ColorIndex = 16
End With
End Sub


Sub EnableButton()
Dim shpbtn As Shape
Dim bnt As Button
Set btn = ActiveSheet.Buttons("Button 2")
Set shpbtn = ActiveSheet.Shapes("Button 2")
With shpbtn
.ControlFormat.Enabled = True
.TextFrame.Characters( _
Start:=1, Length:=Len(btn.Caption)) _
.Font.ColorIndex = xlAutomatic
End With
End Sub
"Paul James" wrote in message
...
Thanks, Tom.

Yes,

worksheets("sheetName").Buttons("cmdName").enabled = false


works fine, because this button was created from the Forms toolbar.
However, I'm still looking for a way to "gray-out" the button, or provide
some other visual cue when it's disabled. When I only set the enable
property to false, the button's appearance doesn't change in any way, and
the cursor still changes to the white hand when it's placed over the

button,
implying that it's active, even though it isn't.

Do you know of a way to provide a visual cue that the button is disabled
without making it invisible?