自定义功能区 onAction 语法问题
我按照此处的说明创建自定义功能区对于 Access 应用程序。但所有按钮都不起作用!我不断收到一条错误,指出 Access 无法找到该函数或宏,即使它是公共的且位于标准模块中。
最终我发现,如果我使用以下语法,它就会起作用:
onAction="=fncMyFunction('string argument', 1234)"
fncMyFunction
接收手动输入的参数,但不是功能区对象。
在另一个项目的 Word 中,我通过将文档作为 .ZIP 文件打开、在适当的位置添加 XML 并添加对其的引用来创建自定义功能区。 小说中的相关说明位于此处。
在 Word 中,我能够使用以下语法让一切按照我预期的方式工作:
onAction="fncMyFunction"
在 Word 中,fncMyFunction
将一个功能区对象传递给单击按钮时。
这是怎么回事?为什么语法不同?其中一种方式是“错误的”吗?
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?"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该使用功能区元素的
tag
属性来存储一些要传递给操作的值。例如,假设您有一个包含几个按钮的简单功能区:
ribbonOpenForm
,单击时会打开一个表单FormDashBoardFinance
。ribbonDoAction
来执行LogOff("bye")
VBA 函数(不是 Sub!),例如,向用户显示一条消息并注销。fncMyFunction()
行为。管理功能区的 VBA 将位于一个模块中:
Avenius Gunter 的 Access 2010 Ribbon 站点 是 Access Ribbon 的优秀资源。
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