ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting a hook on Toolbar Events (https://www.excelbanter.com/excel-programming/363692-getting-hook-toolbar-events.html)

WhytheQ

Getting a hook on Toolbar Events
 
How could I trap toolbar events: I'd like a boolean variable to change
when a custom toolbar has been made invisible i.e it is a floating
custom toolbar and I'd like a boolean variable to change when the user
hits the cross to make the bar invisible.

Is a class module the only answer?

Regards
Jason.


Ardus Petus

Getting a hook on Toolbar Events
 
bVisible = commandbars("My Command Bar").visible

HTH
--
AP

"WhytheQ" a écrit dans le message de news:
...
How could I trap toolbar events: I'd like a boolean variable to change
when a custom toolbar has been made invisible i.e it is a floating
custom toolbar and I'd like a boolean variable to change when the user
hits the cross to make the bar invisible.

Is a class module the only answer?

Regards
Jason.




Jim Thomlinson

Getting a hook on Toolbar Events
 
There is no event that fires when the visible property of a command bar is
changed so I am affraid you are out of luck on this one.
--
HTH...

Jim Thomlinson


"WhytheQ" wrote:

How could I trap toolbar events: I'd like a boolean variable to change
when a custom toolbar has been made invisible i.e it is a floating
custom toolbar and I'd like a boolean variable to change when the user
hits the cross to make the bar invisible.

Is a class module the only answer?

Regards
Jason.



keepITcool

Getting a hook on Toolbar Events
 

You dont need events or hooks.
Simply use protection for your bar (see VBA help for details):

Sub ObstinateBar()
On Error Resume Next
CommandBars("Test").Delete
On Error GoTo 0

With CommandBars.Add("Test", msoBarFloating, , True)
With .Controls.Add(msoControlButton, , , , True)
.Caption = "Button"
.FaceId = 59
.OnAction = " BtnHandler"
End With
.Visible = True
.Protection = msoBarNoChangeDock + _
msoBarNoChangeVisible + _
msoBarNoCustomize
End With

'OfficeXP has a few more options
'Following code will compile and work in versions 97-2003
#If VBA6 Then
If Val(Application.Version) 10 Then
CallByName CommandBars, "DisableAskAQuestionDropdown", VbLet, True
CallByName CommandBars, "DisableCustomize", VbLet, True
End If
#End If

End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


WhytheQ wrote in
groups.com

How could I trap toolbar events: I'd like a boolean variable to change
when a custom toolbar has been made invisible i.e it is a floating
custom toolbar and I'd like a boolean variable to change when the user
hits the cross to make the bar invisible.

Is a class module the only answer?

Regards
Jason.


WhytheQ

Getting a hook on Toolbar Events
 
as per usual where others give up, KeepItCool comes up with the goods:
Thanks!
J


keepITcool wrote:
You dont need events or hooks.
Simply use protection for your bar (see VBA help for details):

Sub ObstinateBar()
On Error Resume Next
CommandBars("Test").Delete
On Error GoTo 0

With CommandBars.Add("Test", msoBarFloating, , True)
With .Controls.Add(msoControlButton, , , , True)
.Caption = "Button"
.FaceId = 59
.OnAction = " BtnHandler"
End With
.Visible = True
.Protection = msoBarNoChangeDock + _
msoBarNoChangeVisible + _
msoBarNoCustomize
End With

'OfficeXP has a few more options
'Following code will compile and work in versions 97-2003
#If VBA6 Then
If Val(Application.Version) 10 Then
CallByName CommandBars, "DisableAskAQuestionDropdown", VbLet, True
CallByName CommandBars, "DisableCustomize", VbLet, True
End If
#End If

End Sub


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


WhytheQ wrote in
groups.com

How could I trap toolbar events: I'd like a boolean variable to change
when a custom toolbar has been made invisible i.e it is a floating
custom toolbar and I'd like a boolean variable to change when the user
hits the cross to make the bar invisible.

Is a class module the only answer?

Regards
Jason.




All times are GMT +1. The time now is 03:35 AM.

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