Macros/Base/001

Description
We would like to manage images without incorporating them in the database. The advantage is that it avoids duplication and especially to not increase the size of the database.

This feature is accessible without a macro (see Faq/Base/144). We will see here the properties concerned can be managed via a macro. The desired result is as shown:




 * The top Text Box allows retrieval of the image via a local filepath or URL.
 * The File Selection button "..." opens a dialog to select local filepath.
 * The bottom Text Box allows for entering a title to the image.
 * The Image Control allows for displaying the image.

We can realize the above via the two subroutines as shown below.

Code
In LibreOffice Basic:

The subroutine display_image is associated with the following events:
 * After a change in saving of the form,
 * If the Image Control receives focus.

The subroutine save_path is associated with the following events:
 * Loss of focus for a Text Box,
 * Modified text from the File Selection object.

Example ODB file

 * [[Media:FR.MACROS Base 001 Gestion images liees par macros.odb|Download odb file with this macro embedded]]