英文:
Do Event Macros have a self-reference capacity like Me or This?
问题
我想要一系列按钮,点击后使用宏来创建一个包含按钮标题的TempVar。
我真的不想使用VBA,因为表单中的其他所有内容都是宏。
目前,我有一个使用以下选择器创建TempVar的宏:
[Command5].[Caption]
但是,我想用[Me]或[This]来替代[Command5]。这样我就可以复制粘贴按钮,而不必打开每个新按钮并更新控件名称。
英文:
I'd like to have a series of buttons that after being clicked, use a macro to create a TempVar containing the caption of the button.
I really don't want to have to use VBA, as everything else in the form is a macro.
At the moment, I have a macro that creates a Tempvar using this selector:
[Command5].[Caption]
However, I'd like to replace [Command5] with something Me or This. Then I could copy & paste the button without having to open each new one and update the control name.
答案1
得分: 1
你可以使用[Screen].[ActiveControl]
方法。设置临时变量如下-
[Screen].[ActiveControl].[Caption]
然后将tempvar用于进一步操作。请参考下面的截图以获得更清晰的图示。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论