I want to create a custom menu in Ms Access 2003 to automate some processing of VBA code. It's easy to create a custom toolbar and controls for use with forms, reports, etc; and I can create a toolbar visible and usable on the VBA side. But I've not succeeded, neither by interaction nor by vba, in populating the toolbar with custom (macro) controls, which is what I need to do. Searching for help always leads to instructions as to how to customise toolbars for the database, but NOT for the code. Advice would be much appreciated.
Asked
Active
Viewed 5,497 times
1 Answers
2
From the MS website: http://msdn.microsoft.com/en-us/library/office/aa210698(v=office.11).aspx
'Create a commandbar
Dim cmb As CommandBar
Set cmb = Application.CommandBars.Add("MyCommandBar")
cmb.Visible = True
'Add a command button
Dim cbc As CommandBarControl
Set cbc = cmb.Controls.Add(msoControlButton)
cbc.Caption = "Button1"
cbc.Style = msoButtonCaption
'Add code to execute when button is pressed
CommandBars("MyCommandBar").Controls("Button1").OnAction = "=MsgBox(""Wow!"")"
You could specify a macro in place of the "MsgBox".

Trebor
- 33
- 5