如何获取我在 libreoffice calc(宏)中选中的复选框的名称?

How to get the name of checkbox that I checked in libreoffice calc (macro)?

我在一个计算中有 40 多个复选框 sheet,我不想对每个复选框都进行编码。我只想要一个清晰的工作代码来 获取复选框的名称

在此程序中,我必须在宏代码中手动键入复选框的名称:

A="CheckBox1"

这是我目前的全部:

Sub Marco1
    Dim ocheckbox1
    Dim oForm
    Dim A
    A="CheckBox1"
    oForm = ThisComponent.Sheets(0).DrawPage.Forms.getByIndex(0)
    ocheckbox1 = oForm.getByName(A)
    if ocheckbox1.State = "0" then
        if MsgBox ("Are you sure ?Note: It can't be re-edited", 292) = 6 then
            ocheckbox1.Label = "Checked"
            ocheckbox1.Enabled="False"
        else
            ocheckbox1.Label = "Not Checked"
        End if
    End if
End Sub

假设宏是通过与复选框的交互触发的:

Sub Macro1 (oEvent As Object)
    Dim oCheckbox1 As Object
    Dim sCheckbox1Name As String

    oCheckbox1 = oEvent.source.model
    sCheckbox1Name = oCheckbox1.Name
End Sub