0

我正在尝试创建一个简单的宏来控制已放置在表单中的两个按钮。它们交替位置,因此它们可以被按下或不被按下,目标是只按下其中一个。我的想法是每次按下两者中的一个时执行一个宏,而宏将负责取消按下另一个。

有任何想法吗?

非常感谢!

4

1 回答 1

0

以下代码来自https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=34337。它适用于基本形式以及 Calc。

Sub subButtonDisableButton2(Event As Object)
   Dim oForm As Object
   Dim oModelButton As Object
   'We get the model of the form from the button who calls the macro
   oForm=Event.Source.Model.Parent
   'Now we get the model of button2
   oModelButton=oForm.GetByName("button2")
   'And we disable it!
   oModelButton.Enabled=False
End Sub

或者使用单选按钮,这通常表示一次只能选择一个。

于 2017-10-04T12:20:09.197 回答