Greg Truby
MrExcel MVP
- Joined
- Jun 19, 2002
- Messages
- 10,025
OK - I'm startin' to feel a bit loopy from too much of this I have looked through all 9 threads returned from a search on terms button, state, msoButtonDown and from what I can see, what I want to do should be possible. But it just ain't workin' for me.
The problem: I have my own little versions of the Formatting and Standard toolbars that I've doctored up to suit my needs. On my "CustomStandard" bar, I've a regular custom button that toggles the VB toolbar's visibility back and forth. I stumbled across the .State property and thought "hey, that looks like a way I can make some of my buttons act like the Bold, Italic buttons, etc.". i.e. the show down/up per the environment. But I cannot get it to even return a state of "msoButtonDown" even when it's running the assigned macro, much less get it to stick in a state of "msoButtonDown". I'm running XL2002. Am I doing something wrong here?
Here's the code I've tried (I pulled the lines that returned the .State property out, but it always returns msoButtonUp. The beginGroup bit was to make sure I was hitting the correct button - that worked - I've got the right button.)
<font face=Courier New><SPAN style="color:#007F00">'------------------------------------------------------------------------------</SPAN>
<SPAN style="color:#00007F">Sub</SPAN> ToggleVBToolbar()
<SPAN style="color:#00007F">Dim</SPAN> cbButton <SPAN style="color:#00007F">As</SPAN> CommandBarButton
<SPAN style="color:#00007F">Set</SPAN> cbButton = CommandBars("CustomStandard").Controls("Visual Basic Toolbar")
Application.CommandBars("Visual Basic").Visible = <SPAN style="color:#00007F">Not</SPAN> Application.CommandBars("Visual Basic").Visible
<SPAN style="color:#00007F">If</SPAN> Application.CommandBars("Visual Basic").Visible <SPAN style="color:#00007F">Then</SPAN>
cbButton.State = msoButtonDown
<SPAN style="color:#007F00">'cbButton.BeginGroup = True</SPAN>
MsgBox "down"
<SPAN style="color:#00007F">Else</SPAN>
cbButton.State = msoButtonUp
<SPAN style="color:#007F00">'cbButton.BeginGroup = False</SPAN>
MsgBox "up"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
Thanks for any help y'all can offer.
The problem: I have my own little versions of the Formatting and Standard toolbars that I've doctored up to suit my needs. On my "CustomStandard" bar, I've a regular custom button that toggles the VB toolbar's visibility back and forth. I stumbled across the .State property and thought "hey, that looks like a way I can make some of my buttons act like the Bold, Italic buttons, etc.". i.e. the show down/up per the environment. But I cannot get it to even return a state of "msoButtonDown" even when it's running the assigned macro, much less get it to stick in a state of "msoButtonDown". I'm running XL2002. Am I doing something wrong here?
Here's the code I've tried (I pulled the lines that returned the .State property out, but it always returns msoButtonUp. The beginGroup bit was to make sure I was hitting the correct button - that worked - I've got the right button.)
<font face=Courier New><SPAN style="color:#007F00">'------------------------------------------------------------------------------</SPAN>
<SPAN style="color:#00007F">Sub</SPAN> ToggleVBToolbar()
<SPAN style="color:#00007F">Dim</SPAN> cbButton <SPAN style="color:#00007F">As</SPAN> CommandBarButton
<SPAN style="color:#00007F">Set</SPAN> cbButton = CommandBars("CustomStandard").Controls("Visual Basic Toolbar")
Application.CommandBars("Visual Basic").Visible = <SPAN style="color:#00007F">Not</SPAN> Application.CommandBars("Visual Basic").Visible
<SPAN style="color:#00007F">If</SPAN> Application.CommandBars("Visual Basic").Visible <SPAN style="color:#00007F">Then</SPAN>
cbButton.State = msoButtonDown
<SPAN style="color:#007F00">'cbButton.BeginGroup = True</SPAN>
MsgBox "down"
<SPAN style="color:#00007F">Else</SPAN>
cbButton.State = msoButtonUp
<SPAN style="color:#007F00">'cbButton.BeginGroup = False</SPAN>
MsgBox "up"
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
Thanks for any help y'all can offer.