S
Stuart Grant
I have a workbook which starts by adding to new items to the standard menu
bar List and Transactions. (I realise List is perhaps not a good name since
it is used by Excel but it hasn't caused any trouble and I can change it if
it does).
The MakeSubMenus is as follows
Sub MakeSubMenus()
Dim Bar As Object
Set Bar = MenuBars(xlWorksheet)
Bar.Reset
'Create new Menus
Bar.Menus.Add Caption:="&List"
Bar.Menus.Add Caption:="&Transactions"
Set ListMenu = Bar.Menus("&List")
Set TransactionsMenu = Bar.Menus("&Transactions")
'Create menu items
With ListMenu.MenuItems
.AddMenu "&Account Details"
.AddMenu "&Income/Expenditure"
.AddMenu "&Balance Sheet"
End With
With TransactionsMenu.MenuItems
.AddMenu "&Record"
.AddMenu "&List by Account"
.AddMenu "List by &Month"
End With
End Sub
It works fine. I want however to add a macro to each of the menu items -
Account Details etc. I tried assigning the macros after the program starts
using Customize etc.. That works but when I end the program, next time I
start, the assignment has gone. I assume I have to use an OnAction
statement attached to each of the menu items to specify the macro(Sub) but I
can't figure out the syntax. I guess I'm not Object-Orientated enough !
Can anyone help.
Stuart
bar List and Transactions. (I realise List is perhaps not a good name since
it is used by Excel but it hasn't caused any trouble and I can change it if
it does).
The MakeSubMenus is as follows
Sub MakeSubMenus()
Dim Bar As Object
Set Bar = MenuBars(xlWorksheet)
Bar.Reset
'Create new Menus
Bar.Menus.Add Caption:="&List"
Bar.Menus.Add Caption:="&Transactions"
Set ListMenu = Bar.Menus("&List")
Set TransactionsMenu = Bar.Menus("&Transactions")
'Create menu items
With ListMenu.MenuItems
.AddMenu "&Account Details"
.AddMenu "&Income/Expenditure"
.AddMenu "&Balance Sheet"
End With
With TransactionsMenu.MenuItems
.AddMenu "&Record"
.AddMenu "&List by Account"
.AddMenu "List by &Month"
End With
End Sub
It works fine. I want however to add a macro to each of the menu items -
Account Details etc. I tried assigning the macros after the program starts
using Customize etc.. That works but when I end the program, next time I
start, the assignment has gone. I assume I have to use an OnAction
statement attached to each of the menu items to specify the macro(Sub) but I
can't figure out the syntax. I guess I'm not Object-Orientated enough !
Can anyone help.
Stuart