View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Can't get Control.State to work

wal brought next idea :
Isn't .State what causes a button to be "dark" vs. not? And doesn't
"dark" = down still allow the button to be pressed? For example, if
you run the following code for the Bold button, when the button is
"light" = up (and the text in the cell not bold), the result is 0 =
msoButtonUp; if the button is "dark" = down (cell text is bold), the
result is -1 = msoButtonDown and the button still works to toggle the
bold attribute.

Dim myBar As CommandBar, myControl As CommandBarButton
Set myBar = CommandBars("myFormatting")
Set myControl = myBar.Controls("Bold")
MsgBox myControl.State

Thanks for the sample code, which I'll try later. (I'm still curious
as to why the button can't be made to become dark by setting
the .State.)


So are you using an actual CommandButton or are you trying to
manipulate a menuitem. In the case of the menuitem it might work better
if you set its 'checked' value to reflect the calc mode. Either way,
you have to validate the state to the current mode and update the
control accordingly. Given the numerous ambiguities associated with
either method, I've always found it easier (and more reliable) to
change the caption so it reflects the current state and suggests what
change will occur when clicked.

I do recall some info in a book by John Walkenback (or Rob Bovey) on
this. I'll try to find it and post back if nobody else responds...

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc