我想用 Basic 迭代 LibreOffice 表单中的控件。
基本上,我想做这段代码在 VBA 中所做的事情。
Sub parcours_controles_formulaire()
Dim cControl As Control
Dim sLog As String
sLog = "List of controls : " & vbCrLf
For Each cControl In FrmExemplesControles.Controls
sLog = sLog & _
cControl.Name & _
" of type " & _
TypeName(cControl) & vbCrLf
Next cControl
MsgBox sLog
End Sub
编辑:这是我在 Lyrl 的帮助下发现的。这还不完全正确。我无法获得控件的标签。
Sub iterate_forms_controls()
Dim Dlg As Object
Dim Controls As Object
Dim cControl As Object
Dim I As Integer
Dim A As String
DialogLibraries.LoadLibrary("Standard")
Dlg = CreateUnoDialog(DialogLibraries.Standard.BoiteDeDialogue1)
Controls = Dlg.Controls
I = 0
A = ""
For Each cControl In Controls
I = I + 1
A = A & cControl.getImplementationName()
'A = A & cControl ' How to get back the label of cControl here ?
Next cControl
MsgBox "There is " & i & " controls in that form !" & A
End Sub