Thread: Toolbars
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Doug Glancy Doug Glancy is offline
external usenet poster
 
Posts: 770
Default Toolbars

TK,

You need to use the Workbook_Acitivate, Workbook_Deactivate and
Workbook_BeforeClose events in the ThisWorkbook module. I think that's all
you need, but I always have to re-educate myself when creating menus. I've
found it useful to create these different events and put simple msgbox
messages in them, e.g., "book1 deactivated", "sheet1 activated", etc., so I
can understand when they occur. Doing so will show that switching between
workbooks does not fire the Worksheet_Deactivate event. On the other hand,
the Workbook_Activate event is fired when a workbook is opened, so I don't
think you need to use the Workbook_Open event for menu creation.

hth,

Doug Glancy

"TK" wrote in message
...
Thanks

Bob / Jim / Doug

In clarification the procedures (functions) work ok and the
Set cbrCommandBar =... Temporary:=True
so if the workbook (wb1)is opened then closed all is good.

However, if another workbook is opened before wb1 is closed
the toolbar is still visible in that workbook.
So I need to toggle the functions when wb1 is the active
workbook and when it is not.

I hope helps you to help me.

Thanks
TK


"Doug Glancy" wrote:

TK,

I'm not sure I'm understanding exactly, but I think you would be better
off
actually deleting the toolbar, rather than setting visible to false.
Typically the create module also starts by deleting the toolbar:

on error resume next 'if there's no toolbar you won't get error
mybar.delete
on error goto 0

This way you don't get the error that comes from creating a toolbar that
already exists.

hth,

Doug Glancy

"TK" wrote in message
...
Hi

I have a function in a module that creates a toolbar with VBA.
"ShowToolBar"
Also a function that deletes (set visual to False).
"HideToolBar"
Now for example:
Wb1 has the modual and then wb2 is opened but wb1 is still open
but inactive, I would like to delete the toolbar when wb2 opens.
When wb2 becomes inactive or whenever wb1 becomes active
again I would like to restore the toolbar.

I have called the function from Worksheet_Activate
WorkSheetDeactivate; Workbook_Open / Close all without
much happiness.

Any help would be greatly appreciated.