Reputation: 201
I created a custom ribbon using Custom UI Editor For Microsoft Office
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabHome" >
<group id="customGroup1" label="My Group" insertAfterMso="GroupEditingExcel">
<button id="customButton1" label="Click Me" size="large" onAction="test()" imageMso="HappyFace" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I saved excel 2007 file as Excel Macro-Enabled workbook
Here is my macro. It works fine when it run manually
Sub test()
For i = 1 To 10
For j = 1 To i
Cells(i, j) = j
Next
Next
End Sub
But When I press the smiling face button in my custom ribbon it gives following error message.
cannot run the macro 'test()' the macro may not be available in this workbook or all macro may be disabled.
How can I fix this issue ? Any suggestions ?
Thank you
Upvotes: 0
Views: 944
Reputation: 2986
You should not include the brackets. So change this:
onAction="test()"
to:
onAction="test"
Also, make sure the routine name is unique and does not exist in any other workbook you might have open in Excel, otherwise you risk the wrong routine being called.
Upvotes: 1