2017-10-04 76 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 

或使用單選按鈕,通常表示一次只能選擇一個。