PC Review


Reply
Thread Tools Rate Thread

Deactivate workbook commandbar for one sheet?

 
 
mitchellwma1@yahoo.com
Guest
Posts: n/a
 
      18th Oct 2006
I've never run into this one before. I usu. need a repeating toolbar
for any sheet in a workbook. Therefore, in the "ThisWorkbook" I copy
this code into each new workbook I make that uses a custom commandbar:



Private Sub Workbook_Activate()
On Error Resume Next
Application.CommandBars("My Assigned Toolbar Name").Visible = True
End Sub
Private Sub Workbook_Deactivate()
' CommandBars disappear (whilst the workbook remains open, but another
is in view)
On Error Resume Next
Application.CommandBars("My Assigned Toolbar Name").Visible = False
End Sub



So that takes care of activating the custom toolbar on workbook open,
and deactivating it on workbook close and the toolbar shows up on any
sheet I create within that workbook.

But, what does one do if one wants to "hide" the toolbar for sheet 2,
say?

Thanks. D

 
Reply With Quote
 
 
 
 
acampbell012@yahoo.com
Guest
Posts: n/a
 
      18th Oct 2006
In the sheet module of the sheet you want to hide the menu:

Private Sub Worksheet_Activate()
Application.CommandBars("My Assigned Toolbar Name").Visible = False
End Sub

To redisplay the menu when selecting another sheet, place this in the
same module:

Private Sub Worksheet_Deactivate()
Application.CommandBars("My Assigned Toolbar Name").Visible = True
End Sub

mitchellw...@yahoo.com wrote:
> I've never run into this one before. I usu. need a repeating toolbar
> for any sheet in a workbook. Therefore, in the "ThisWorkbook" I copy
> this code into each new workbook I make that uses a custom commandbar:
>
>
>
> Private Sub Workbook_Activate()
> On Error Resume Next
> Application.CommandBars("My Assigned Toolbar Name").Visible = True
> End Sub
> Private Sub Workbook_Deactivate()
> ' CommandBars disappear (whilst the workbook remains open, but another
> is in view)
> On Error Resume Next
> Application.CommandBars("My Assigned Toolbar Name").Visible = False
> End Sub
>
>
>
> So that takes care of activating the custom toolbar on workbook open,
> and deactivating it on workbook close and the toolbar shows up on any
> sheet I create within that workbook.
>
> But, what does one do if one wants to "hide" the toolbar for sheet 2,
> say?
>
> Thanks. D


 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      18th Oct 2006
Put the hide code in the worksheet activate code for that worksheet, and the
show code in the deactivate event.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I've never run into this one before. I usu. need a repeating toolbar
> for any sheet in a workbook. Therefore, in the "ThisWorkbook" I copy
> this code into each new workbook I make that uses a custom commandbar:
>
>
>
> Private Sub Workbook_Activate()
> On Error Resume Next
> Application.CommandBars("My Assigned Toolbar Name").Visible = True
> End Sub
> Private Sub Workbook_Deactivate()
> ' CommandBars disappear (whilst the workbook remains open, but another
> is in view)
> On Error Resume Next
> Application.CommandBars("My Assigned Toolbar Name").Visible = False
> End Sub
>
>
>
> So that takes care of activating the custom toolbar on workbook open,
> and deactivating it on workbook close and the toolbar shows up on any
> sheet I create within that workbook.
>
> But, what does one do if one wants to "hide" the toolbar for sheet 2,
> say?
>
> Thanks. D
>



 
Reply With Quote
 
mitchellwma1@yahoo.com
Guest
Posts: n/a
 
      18th Oct 2006
Well, that is just so neat. That worked great. I just put the
opposite to what is in the workbook module into the sheet module, as
per the above. i.e., where it says for the toolbar to show (true) in
the workbook, I hide it in the worksheet (false). That's too neat for
words.

It was hoping it would be that simple.

thx!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save each sheet of multi-sheet workbook as a single-sheet workbook CTB Microsoft Excel Programming 3 17th May 2011 08:40 AM
Workbook Deactivate incjourn Microsoft Excel Programming 1 14th Sep 2004 02:51 PM
Saving CommandBar with Workbook pjd Microsoft Excel Worksheet Functions 0 12th Jul 2004 09:44 AM
Sort sheet on sheet's Deactivate event BountyHunter Microsoft Excel Programming 3 25th May 2004 08:31 AM
UserForms to deactivate workbook Patrick Marion Microsoft Excel Programming 1 20th Dec 2003 05:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:29 PM.