commandbar button call macro

Jaye7

Registered User.
Local time
Today, 23:16
Joined
Aug 19, 2014
Messages
205
I have the following script to add a commandbar, however I can not get the onaction script to call the macro, the macro is located in a module.

Code:
Sub AccessButton1()

On Error Resume Next
CommandBars("MyCommandBar").Delete
      
    
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 = msoButtonIconAndCaption
cbc.OnAction = "=test3()"

end sub
 
funny that if I put the script as a function it will work, but not as a vba macro

Code:
Function test3()
 MsgBox "Good To Go"
 End Function
 
Last edited:

Users who are viewing this thread

Back
Top Bottom