Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Wei Wei is offline
external usenet poster
 
Posts: 8
Default How to hide toolbar automatically when I switch to other worksheet

I have five worksheets in one workbook. I try to make a tool bar just for the
one worksheet(name is class) and is only visible when the "class" sheet is
active?
Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default How to hide toolbar automatically when I switch to other worksheet

I suspect you'll need to do this with VBA. You'd turn on the toolbar when
the worksheet is activated and turn if off when it's not. I've linked some
code that may work.

http://www.bygsoftware.com/Excel/VBA..._menu_demo.htm


"Wei" wrote:

I have five worksheets in one workbook. I try to make a tool bar just for the
one worksheet(name is class) and is only visible when the "class" sheet is
active?
Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.misc
Wei Wei is offline
external usenet poster
 
Posts: 8
Default How to hide toolbar automatically when I switch to other works

Barb,
Thanks so much, is there any way to add the custom popup menu to the
default menu list instead disable the default menu? I just begin to learn VBA.
Wei


"Barb Reinhardt" wrote:

I suspect you'll need to do this with VBA. You'd turn on the toolbar when
the worksheet is activated and turn if off when it's not. I've linked some
code that may work.

http://www.bygsoftware.com/Excel/VBA..._menu_demo.htm


"Wei" wrote:

I have five worksheets in one workbook. I try to make a tool bar just for the
one worksheet(name is class) and is only visible when the "class" sheet is
active?
Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,355
Default How to hide toolbar automatically when I switch to other works

Put this code in the "ThisWorkbook" Module

Private Sub Workbook_Open()

Call CreatePopup


End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Call DeleteMenus

End Sub


Create a new module and put this in:

Dim cbpop As CommandBarControl
Dim cbctl As CommandBarControl
Dim cbMilestoneSortSubMenu As CommandBarControl

Sub CreatePopup()
'These set the popup menus to be the same for Worksheets and charts.
They could be different
Call createPopupMenus("Worksheet menu bar")
Call createPopupMenus("Chart menu bar")

End Sub

Private Sub createPopupMenus(menuBarName As String)

Set cbpop =
Application.CommandBars(menuBarName).FindControl(T ype:=msoControlPopup, _
Tag:="ProjectTrackingPopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

' Create a popup control on the a menu bar

Set cbpop = Application.CommandBars(menuBarName). _
Controls.Add(Type:=msoControlPopup, Temporary:=True)
cbpop.Caption = "&My Macros" '<~~~~Change to what you want to display
cbpop.Tag = "PopupTag"
cbpop.Visible = True

' Add a menu item

Set cbctl = cbpop.Controls.Add(Type:=msoControlButton, Temporary:=True)
cbctl.Visible = True
cbctl.Style = msoButtonCaption
cbctl.Caption = "MyMacro" '<~~~change to show what you want to do.
cbctl.OnAction = " MyMacro" '<~~~This is the macro you want to run.
'You'll need to create
that.




End Sub

Sub DeleteMenus()

Dim cbpop As CommandBarControl

Set cbpop = Application.CommandBars("Worksheet menu
bar").FindControl(Type:=msoControlPopup, _
Tag:="PopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

Set cbpop = Application.CommandBars("Chart menu
bar").FindControl(Type:=msoControlPopup, _
Tag:="PopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

End Sub


HTH,
Barb Reinhardt

"Wei" wrote:

Barb,
Thanks so much, is there any way to add the custom popup menu to the
default menu list instead disable the default menu? I just begin to learn VBA.
Wei


"Barb Reinhardt" wrote:

I suspect you'll need to do this with VBA. You'd turn on the toolbar when
the worksheet is activated and turn if off when it's not. I've linked some
code that may work.

http://www.bygsoftware.com/Excel/VBA..._menu_demo.htm


"Wei" wrote:

I have five worksheets in one workbook. I try to make a tool bar just for the
one worksheet(name is class) and is only visible when the "class" sheet is
active?
Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.misc
Wei Wei is offline
external usenet poster
 
Posts: 8
Default How to hide toolbar automatically when I switch to other works

Thank you so much!
Happy July 4th!
Wei

"Barb Reinhardt" wrote:

Put this code in the "ThisWorkbook" Module

Private Sub Workbook_Open()

Call CreatePopup


End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Call DeleteMenus

End Sub


Create a new module and put this in:

Dim cbpop As CommandBarControl
Dim cbctl As CommandBarControl
Dim cbMilestoneSortSubMenu As CommandBarControl

Sub CreatePopup()
'These set the popup menus to be the same for Worksheets and charts.
They could be different
Call createPopupMenus("Worksheet menu bar")
Call createPopupMenus("Chart menu bar")

End Sub

Private Sub createPopupMenus(menuBarName As String)

Set cbpop =
Application.CommandBars(menuBarName).FindControl(T ype:=msoControlPopup, _
Tag:="ProjectTrackingPopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

' Create a popup control on the a menu bar

Set cbpop = Application.CommandBars(menuBarName). _
Controls.Add(Type:=msoControlPopup, Temporary:=True)
cbpop.Caption = "&My Macros" '<~~~~Change to what you want to display
cbpop.Tag = "PopupTag"
cbpop.Visible = True

' Add a menu item

Set cbctl = cbpop.Controls.Add(Type:=msoControlButton, Temporary:=True)
cbctl.Visible = True
cbctl.Style = msoButtonCaption
cbctl.Caption = "MyMacro" '<~~~change to show what you want to do.
cbctl.OnAction = " MyMacro" '<~~~This is the macro you want to run.
'You'll need to create
that.




End Sub

Sub DeleteMenus()

Dim cbpop As CommandBarControl

Set cbpop = Application.CommandBars("Worksheet menu
bar").FindControl(Type:=msoControlPopup, _
Tag:="PopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

Set cbpop = Application.CommandBars("Chart menu
bar").FindControl(Type:=msoControlPopup, _
Tag:="PopupTag")
If Not cbpop Is Nothing Then cbpop.Delete

End Sub


HTH,
Barb Reinhardt

"Wei" wrote:

Barb,
Thanks so much, is there any way to add the custom popup menu to the
default menu list instead disable the default menu? I just begin to learn VBA.
Wei


"Barb Reinhardt" wrote:

I suspect you'll need to do this with VBA. You'd turn on the toolbar when
the worksheet is activated and turn if off when it's not. I've linked some
code that may work.

http://www.bygsoftware.com/Excel/VBA..._menu_demo.htm


"Wei" wrote:

I have five worksheets in one workbook. I try to make a tool bar just for the
one worksheet(name is class) and is only visible when the "class" sheet is
active?
Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
switch from one worksheet to another without using mouse Jamie Excel Discussion (Misc queries) 2 June 22nd 07 10:26 PM
Switch between worksheet tabs? LovelyKillerGal Excel Discussion (Misc queries) 3 May 2nd 07 01:55 AM
auto hide toolbar in Excel won't work teecee8 Excel Discussion (Misc queries) 5 July 22nd 05 06:08 AM
How do I automatically hide columns in a worksheet based on a cell value? dkhedkar Excel Worksheet Functions 1 March 5th 05 12:20 AM
How do I hide a worksheet in Excel and use a password to un-hide . Dchung Excel Discussion (Misc queries) 3 December 2nd 04 06:24 AM


All times are GMT +1. The time now is 09:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"