2017-10-04 75 views
0

我试图创建一个简单的宏来控制已放置在窗体中的两个按钮。他们交替的位置,所以他们可以被按下或不按下,目标是只有他们中的一个按下。我的想法是在每次按下其中一个按钮时执行宏,并且宏将负责不压迫另一个宏。从宏中获取按钮(LibreOffice)

任何想法?

非常感谢!

回答

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 

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