- work with objects in the Object Catalog and Basic Macro Organizer
- create a library
- create a module
- create and delete dialogs
- export and import a dialog
- create a cloned copy of a dialog with a new name.
When working with dialogs, the objects you will most commonly be working with are libraries, modules, and dialogs. These are created and deleted in the Basic Macro Organizer.
Create a new odb file named newDatabase.odb. Go to the Tools menu -> Macros -> Edit Macros. This puts you in the Basic IDE, with the Object Catalog to the left. In the tool bar immediately under the menus, find the icon with the magenta and white scroll with a blue sprocket at the lower right. Click that.
You are now in the Basic Macro Organizer. The last thing listed should be your project file, named newDatabase.odb. Double click on that.
Now you see the project's libraries, represented by icons with yellow folders behind magenta and white scrolls.
The default library is named Standard. Double click on that.
There are no modules in the Standard library. Click on the New button, and create the Module1 module. This will be represented by a magenta and white scroll.
Still in the Basic Macro Organizer, click on the Libraries tab. Near the top is a listbox. Click on the listbox and select newDatabase.odb. The default library, Standard, is the only one listed. Click the New button and type "Dialogs".
Click on the Dialogs tab. Double click on newDatabase.odb. You will see the Dialogs and Standard libraries. Double click on the Dialogs library and click the New button. Type "dlgFirstName" and save the new dialog, represented by a square blue and white icon. Now click on the dialog name. The blue area should shrink to cover only the name. You can now edit the name. Change the name to "dlgSecondName". Click anywhere outside the name or press the Enter key and your edit will be saved.
Find dialog design view:
A lot of the tasks you want to perform must be done in dialog design view. But the steps for entering dialog design view are different from the steps for entering design view for any other object.
Go to the Tools menu -> Macros -> Edit Macros. In the Object Catalog to the left, navigate to dlgSecondName. Double click on the dialog name. Now move the mouse pointer across the border of the dialog until it turns into a cross with four outward pointing arrows. Click on the border. A listing of properties appears in the Object Catalog. To save changes, click on the Save Icon in the tool bar, select Save from the file menu, or press Ctl-s. To exit dialog design view, double click on anything in the Object Catalog that is not a dialog. The properties pane will disappear from the Object Catalog.
N.B. You can't change a dialog's name by changing the Name property. The property will change, but the dialog's name won't. You have to make name changes in the Basic Macro Organizer, as described above.
Exporting dialogs:
Find the dialog and enter design view. Above the Object Catalog pane, and just to the right, are two icons, one with an arrow pointing out, and one with an arrow pointing in. Click on the icon with the arrow pointing out. You will get a Save As dialog box giving you the option of changing the name of the file the dialog is saved to, but don't bother. Changing the file name doesn't change the name of the dialog. Just click Save.
FWIW, you've just created an xml file containing the dialog's properties. When this is imported into another project file, LibreOffice uses the property values to create an exact copy of the dialog.
Importing dialogs:
You're going to import the dialog you just exported. To prepare for that, go to the Basic Macro Organizer and delete the dlgSecondName dialog.
In order to import a dialog into your project file, you must already have a dialog in the file. If you don't have a dialog, you will have to create one. Think of it as a decoy dialog. It's not the dialog you want, but you need it to lure the dialog you do want into your file.
The first section of this tutorial explained how to create a dialog. As a quick review, go to the Basic Macro Organizer and click on the Dialogs tab. Find the Dialogs library. Double click on that library. Click the New button and accept the default name. This is just a decoy that you will delete later.
Close the Basic Macro Organizer and find your decoy dialog in the Object Catalog pane to the left. Click the dialog border to enter dialog design view. Above and immediately to the right of the Object Catalog, find the icon with the inward pointing arrow. Click on that icon and find the dialog file that you previously exported. Select the dialog file, click the Save button, and the imported dialog will open in dialog design view.
You no longer need the decoy dialog. Reopen the Basic Macro Organizer and delete the decoy.
Cloning a dialog w/ a new name:
Some online instructions for making an exact copy of a dialog are very complicated. You're going to make it simple by exploiting a bug in LibreOffice.
Open the dlgSecondName dialog in dialog design view. Click on the border of the dialog to display the property pane in the Object Catalog. Change the Name property to dlgThirdName. Click outside the dialog to save the change. Now export the dialog and reimport it. The new dialog will be an exact copy of dlgSecondName, but it will be named dlgThirdName.
Reopen the original dialog in dialog design view and change the Name property back to the dialog's actual name. In this case, you used the bug intentionally and its effect was beneficial. But if the dialog continues to have a discrepancy between the dialog name and the Name property, the bug could pop up when you don't want it and do something that isn't beneficial.