LibreOffice 25.2 Help
ឧទាហរណ៍ដូចខាងក្រោមគឺសម្រាប់ ប្រអប់ ថ្មីមួយ ហៅថា "Dialog1" ។ ប្រើឧបករណ៍លើរបារ ប្រអប់ឧបករណ៍ក្នុងកម្មវិធីនិពន្ធប្រអប់ ដើម្បីបង្កើតប្រអប់ និងបន្ថែមវត្ថុបញ្ជាដូចខាងក្រោម ៖ ប្រអប់ធីក មួយ ហៅថា "CheckBox1" វាលស្លាក មួយ ហៅថា "Label1" ប៊ូតុង មួយ ហៅថា "CommandButton1" និងប្រអប់បញ្ជី មួយ ហៅថា "ListBox1" ។
ធ្វើឲ្យប្រាកដជាមួយអក្សរធំ និងអក្សរតូច ពេលអ្នកភ្ជាប់វត្ថុបញ្ជាមួយទៅអថេរវត្ថុមួយ ។
Function LoadDialog(Libname as String, DialogName as String, Optional oLibContainer)
Dim oLib as Object ' com.sun.star.script.XLibraryContainer
Dim oLibDialog as Object
Dim oRuntimeDialog as Object
    If IsMissing(oLibContainer) Then
        oLibContainer = DialogLibraries
    End If
    oLibContainer.LoadLibrary(LibName)
    oLib = oLibContainer.GetByName(Libname)
    oLibDialog = oLib.GetByName(DialogName)
    oRuntimeDialog = CreateUnoDialog(oLibDialog)
    LoadDialog() = oRuntimeDialog
End Function
LoadDialog function is stored in Tools.ModuleControls available from Application Macros and Dialogs.
rem global definition of variables
Dim oDialog1 AS Object
Sub StartDialog1
    With GlobalScope.BasicLibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.ModuleControls.LoadDialog("Standard", "Dialog1")
    oDialog1.Execute()
End Sub
Sub Sample1
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.LoadDialog("Standard", "Dialog1")
    REM get dialog model
    oDialog1Model = oDialog1.Model
    REM display text of Label1
    oLabel1 = oDialog1.GetControl("Label1")
    MsgBox oLabel1.Text
    REM កំណត់អត្ថបទថ្មីសម្រាប់ត្រួតពិនិត្យ Label1
    oLabel1.Text = "ឯកសារថ្មី"
    REM បង្ហាញលក្ខណសម្បត្តិម៉ូដែលសម្រាប់ត្រួតពិនិត្យ CheckBox1
    oCheckBox1Model = oDialog1Model.CheckBox1
    MsgBox oCheckBox1Model.Dbg_Properties
    REM កំណត់សភាពថ្មីសម្រាប់ CheckBox1 សម្រាប់ម៉ូដែលនៃវត្ថុបញ្ជា
    oCheckBox1Model.State = 1
    REM បង្ហាញលក្ខណសម្បត្តិម៉ូដែលសម្រាប់ត្រួតពិនិត្យ CommandButton1
    oCMD1Model = oDialog1Model.CommandButton1
    MsgBox oCMD1Model.Dbg_Properties
    REM បង្ហាញលក្ខណសម្បត្តិនៃវត្ថុបញ្ជា CommandButton1
    oCMD1 = oDialog1.GetControl("CommandButton1")
    MsgBox oCMD1.Dbg_Properties
    REM ប្រអប់ប្រតិបត្តិ
    oDialog1.Execute()
End Sub
Sub AddEntry
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = ModuleControls.LoadDialog("Standard", "Dialog1")
    REM បន្ថែមធាតុថ្មីទៅប្រអប់បញ្ជី
    oDialog1Model = oDialog1.Model
    oListBox = oDialog1.GetControl("ListBox1")
    Dim iCount as integer
    iCount = oListbox.ItemCount
    oListbox.additem("New Item" & iCount,0)
End Sub
Sub RemoveEntry
    With GlobalScope.Basiclibraries
       If Not .IsLibraryLoaded("Tools") Then .LoadLibrary("Tools")
    End With
    oDialog1 = Tools.ModuleControls.LoadDialogLoadDialog("Standard", "Dialog1")
    REM យកធាតុទីមួយចេញពី ListBox
    oDialog1Model = oDialog1.Model
    oListBox = oDialog1.GetControl("ListBox1")
    oListbox.removeitems(0,1)
End Sub