I am new to vba so I'm not sure what the error messages mean, but I keep getting this "run-time error '5': invalid procedure call or argument" whenever I run the macro. I select debug and found that this line is causing the error - "Set mybar = Application.CommandBars.Add(Name:="My
Macro", Position:=msoControlButton, Temporary:=True)", but I can' figure out what is wrong with it. It seems to execute this line even after the error message appears. Here is the entire code:
Dim mybar As Object, newcontrol As Object
Set mybar = Application.CommandBars.Add(Name:="My Macro", Position:=msoControlButton, Temporary:=True)
Set newcontrol = mybar.Controls.Add(Type:=msoControlButton, ID _
:=2950, Before:=1)
newcontrol.OnAction = "reducetime"
mybar.Visible = True
It's suppose to create a custom command button in the ribbons in excel 2003, and it actually works but the error always appears when it executes.
Thanks,
Nate