PC Review


Reply
Thread Tools Rate Thread

Command Bar - make it go away when you change sheets

 
 
Darin Kramer
Guest
Posts: n/a
 
      2nd Mar 2007


Hi There,

I have some VB that creates a Command bar (toolbar) and populates it
with buttons which I assign macros too.

I would like to have the toolbar close when any other sheet is selected
(It is launched from say sheet x, and if you click sheet y I want the
toolbar to dissapear (well close!)

Regards

Darin

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      2nd Mar 2007
Add a few event procedures to the ThisWorkbook module of the workbook that
launches the toolbar:

Private Sub Workbook_Activate()
CommandBars("My Toolbar").Visible = True
End Sub

Private Sub Workbook_Deactivate()
CommandBars("My Toolbar").Visible = False
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
CommandBars("My Toolbar").Visible = (Sh.Name = MySheet.Name)
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Darin Kramer" <(E-Mail Removed)> wrote in message
news:%23sEi%(E-Mail Removed)...
>
>
> Hi There,
>
> I have some VB that creates a Command bar (toolbar) and populates it
> with buttons which I assign macros too.
>
> I would like to have the toolbar close when any other sheet is selected
> (It is launched from say sheet x, and if you click sheet y I want the
> toolbar to dissapear (well close!)
>
> Regards
>
> Darin
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      2nd Mar 2007
Darin,

In the Sheet x code module, you need something like this:

Private Sub Worksheet_Activate()
Application.CommandBars("My Command Bar").Visible = True
End Sub
Private Sub Worksheet_Deactivate()
Application.CommandBars("My Command Bar").Visible = False
End Sub


"Darin Kramer" wrote:

>
>
> Hi There,
>
> I have some VB that creates a Command bar (toolbar) and populates it
> with buttons which I assign macros too.
>
> I would like to have the toolbar close when any other sheet is selected
> (It is launched from say sheet x, and if you click sheet y I want the
> toolbar to dissapear (well close!)
>
> Regards
>
> Darin
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Darin Kramer
Guest
Posts: n/a
 
      2nd Mar 2007
Hi Jon,

Almost works - just struggling with syntax of last line...

CommandBars("Functionality_APP_D").Visible = (Sh.Name = APP_D) What Im
doing wrong...?(if my sheet is APP_D)

Regards

D


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      2nd Mar 2007
Is APP_D your sheet name or sheet code name?

If it's the sheet name, it should be like this:

CommandBars("Functionality_APP_D").Visible = (Sh.Name = "APP_D")

If it's the code name, it should be like this:

CommandBars("Functionality_APP_D").Visible = (Sh.Name = APP_D.Name)


"Darin Kramer" wrote:

> Hi Jon,
>
> Almost works - just struggling with syntax of last line...
>
> CommandBars("Functionality_APP_D").Visible = (Sh.Name = APP_D) What Im
> doing wrong...?(if my sheet is APP_D)
>
> Regards
>
> D
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      5th Mar 2007
If the sheet is named "APP_D", then you need to change

CommandBars("Functionality_APP_D").Visible = (Sh.Name = APP_D)
to
CommandBars("Functionality_APP_D").Visible = (Sh.Name = "APP_D")


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Darin Kramer" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Jon,
>
> Almost works - just struggling with syntax of last line...
>
> CommandBars("Functionality_APP_D").Visible = (Sh.Name = APP_D) What Im
> doing wrong...?(if my sheet is APP_D)
>
> Regards
>
> D
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
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
Macro to Select All Sheets and Make Change to Footer Karin Microsoft Excel Misc 2 20th Sep 2008 10:01 PM
command button for open sheets =?Utf-8?B?Z2JwZw==?= Microsoft Excel Programming 0 27th Aug 2007 03:34 PM
SUM command using variable sheets =?Utf-8?B?SWFuQw==?= Microsoft Excel Worksheet Functions 3 18th May 2007 11:56 PM
Make varying numbers of label, change info and make more =?Utf-8?B?S2VudA==?= Microsoft Word Document Management 1 10th May 2006 05:43 AM
Macros to select multiple sheets to make simultaneous change noel Microsoft Excel Misc 2 4th Aug 2004 02:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:44 PM.