I'm trying to create my own toolbar button (commandbarbutton) in Access VBA Editor. Its a button to run a procedure in a public module called "RunTests". I made the button like so:
Public Sub CreateToolbar()
Dim cmdBar As CommandBar
Dim cmdButton As CommandBarButton
Set cmdBar = Application.VBE.CommandBars.Add("Run Tests")
Set cmdButton = cmdBar.Controls.Add(msoControlButton)
cmdButton.FaceId = 558
cmdButton.DescriptionText = "Run the tests"
cmdButton.Caption = "Run Tests"
cmdButton.OnAction = "RunTests"
cmdButton.Enabled = True
cmdButton.Style = msoButtonIconAndCaption
cmdBar.Visible = True
End Sub
I ran the procedure as a test. And it created the button just fine. But the "click" action doesn't respond. The button doesn't seem to be clickable. Does anybody know why?
Edit: Found the solution: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q280607 - I will answer my own question as soon as I can to close it.
Found the solution - To make it work you have to implement the workaround described here: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q280607