I followed the directions here to create a custom ribbon for an Access application. But none of the buttons worked! I kept getting an error that stated Access couldn't find the function or macro, even though it was public and in a standard module.
Eventually I discovered that it would work if I used the following syntax:
onAction="=fncMyFunction('string argument', 1234)"
fncMyFunction
receives the manually typed in arguments, but not the ribbon object.
In Word for another project, I created a custom Ribbon by opening the document up as a .ZIP file, adding the XML in the appropriate place, and adding a reference to it. Relevant directions somewhere in this novel here.
In Word, I was able to have everything work the way I expected it to with the following syntax:
onAction="fncMyFunction"
In Word, fncMyFunction
has a ribbon object passed to it when the button is clicked.
What's the deal here? Why the different syntax? And is one way or the other "wrong?"
You should use the ribbon element's
tag
property to store some values you want to pass to your action.For instance, say you have a simple ribbon containing a few buttons:
ribbonOpenForm
that opens a formFormDashBoardFinance
when clicked.ribbonDoAction
that execute theLogOff("bye")
VBA function (not a Sub!) that, for instance, displays a message to the user and logs off.fncMyFunction()
.The VBA to manage the ribbon would be in a module:
An excellent resource for the Access Ribbon is Avenius Gunter's Access 2010 Ribbon site