ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   toolbars (https://www.excelbanter.com/excel-programming/407298-toolbars.html)

greg

toolbars
 
Hello,
I have a custom toolbar. that I have created by hand. Then attached into a
workbook.
Is there a way to enable or disable buttons on this?
I looked in the object browser. But there does not seem to be any toolbar
object.

thanks



Peter T

toolbars
 
Sub test()
Dim cbr As CommandBar, ctr As Object

Set cbr = Application.CommandBars("MyCustomBar")
cbr.Visible = True ' false

'' either disable the toolbar, uncomment following
' cbr.Enabled = False ' True to re-enable

' or 'grey-out' all the controls
For Each ctr In cbr.Controls
ctr.Enabled = False
Next

End Sub

Regards,
Peter T

"greg" wrote in message
...
Hello,
I have a custom toolbar. that I have created by hand. Then attached into

a
workbook.
Is there a way to enable or disable buttons on this?
I looked in the object browser. But there does not seem to be any toolbar
object.

thanks





Jim Rech[_2_]

toolbars
 
Use the Commandbars object:

Commandbars("MyBar").Controls(1).Enabled = False

or

Commandbars("MyBar").Controls("MyBtn).Enabled = False

It is far better though to create the toolbar "by code" rather than "by
hand". You can attach a toolbar to a workbook but then it takes on a life
of its own. Close the workbook and it's still there. Close Excel and open
it and it's still there...

--
Jim
"greg" wrote in message
...
Hello,
I have a custom toolbar. that I have created by hand. Then attached into
a workbook.
Is there a way to enable or disable buttons on this?
I looked in the object browser. But there does not seem to be any toolbar
object.

thanks





greg

toolbars
 
Ah thanks
toolbars = CommandBars



"Peter T" <peter_t@discussions wrote in message
...
Sub test()
Dim cbr As CommandBar, ctr As Object

Set cbr = Application.CommandBars("MyCustomBar")
cbr.Visible = True ' false

'' either disable the toolbar, uncomment following
' cbr.Enabled = False ' True to re-enable

' or 'grey-out' all the controls
For Each ctr In cbr.Controls
ctr.Enabled = False
Next

End Sub

Regards,
Peter T

"greg" wrote in message
...
Hello,
I have a custom toolbar. that I have created by hand. Then attached
into

a
workbook.
Is there a way to enable or disable buttons on this?
I looked in the object browser. But there does not seem to be any
toolbar
object.

thanks








All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com