Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
switch from one worksheet to another without using mouse | Excel Discussion (Misc queries) | |||
Switch between worksheet tabs? | Excel Discussion (Misc queries) | |||
auto hide toolbar in Excel won't work | Excel Discussion (Misc queries) | |||
How do I automatically hide columns in a worksheet based on a cell value? | Excel Worksheet Functions | |||
How do I hide a worksheet in Excel and use a password to un-hide . | Excel Discussion (Misc queries) |