View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default Worksheet toolbar

When I've set up custom menus for use in a workbook I've found this to work
nicely and without noticeable delay on even older systems without the speed
and power of today's CPUs:

In the Workbook_Open() event, don't do anything regarding menu control.
In the Workbook_Activate() event I create the menu
In the Workbook_Deactivate() event I destroy the menu
and because I usually have separate menus for various sheets:
in the Workbook_SheetActivate() event I go through my create menus process
in the Workbook_SheetDeactivate() I destroy the menu(s)

so perhaps by deleting the menus instead of just hiding them, you may cure
the problem.

"Slim Slender" wrote:

The following code works perfectly on my machine. The custom toolbar
is only visible when one specific sheet is active and disappears when
I switch to another sheet or another workbook. But when the WB is
opened on someone else's machine the toolbar appears and will stay
visible when another WB is activated and then a second copy of it
appears when switching back to the original WB.

Module1

Private Sub Auto_Open()
Call CreateMyCustomToolbar
Worksheets("Database").Activate
End Sub

Public Sub CreateMyCustomToolbar()
Dim i As Long
Dim macro_names As Variant
Dim cap_names As Variant
Dim tip_text As Variant

Call Remove_ToolBars

Stuff to create tool bar goes here

End Sub

Sub Remove_ToolBars()
On Error Resume Next
Application.CommandBars("MyCustomToolbar").Delete
On Error GoTo 0
End Sub


[Sheet4(Database)Code]

Private Sub Worksheet_Activate()
CommandBars("MyCustomToolbar").Visible = True
End Sub

Private Sub Worksheet_Deactivate()
CommandBars("MyCustomToolbar").Visible = False
End Sub


[ThisWorkBook(Code)]

Private Sub Workbook_Activate()
Call CreateMyCustomToolbar
End Sub

Private Sub Workbook_Deactivate()
Call Remove_ToolBars
End Sub
.