GyvWd‖

zGhet‖Document Event-Driven Macros

LRvA8‖This section describes how to assign scripts to application, document or form events.

3G8fP‖You can automatically execute a macro when a specified software event occurs by assigning the desired macro to the event. The following table provides an overview of document events and at what point an assigned macro is executed.

zBhWV‖Event

spcQd‖An assigned macro is executed...

e4Pjb‖routine

WtaR8‖Start Application

otwcA‖...after a LibreOfficeDev application is started.

OnStartApp

zjA7c‖Close Application

iwsSq‖...before a LibreOfficeDev application is terminated.

OnCloseApp

DZHzW‖Document created

KAZDF‖...New document created with File - New or with the New icon. Note that this event also fires when Basic IDE opens.

OnCreate

HBjid‖New Document

fkuXY‖...after a new document is created with File - New or with the New icon.

OnNew

BYGJY‖Document loading finished

jCGwP‖...before a document is opened with File - Open or with the Open icon.

OnLoadFinished

F352r‖Open Document

FGjBU‖...after a document is opened with File - Open or with the Open icon.

OnLoad

H2Uom‖Document is going to be closed

CvPgm‖...before a document is closed.

OnPrepareUnload

kLQvC‖Document closed

DNYcy‖...after a document was closed. Note that the "Save Document" event may also occur when the document is saved before closing.

OnUnload

iMPCi‖-no UI-

OnLayoutFinished

F46jE‖View created

77CWX‖Document is displayed. Note that this event also happens when a document is duplicated.

OnViewCreated

CDwGy‖View is going to be closed

EtV6o‖Document layout is getting removed.

OnPrepareViewClosing

7FemV‖View closed

qGdPR‖Document layout is cleared prior to the document closure.

OnViewClosed

eovzZ‖Activate Document

w5v7V‖...after a document is brought to the foreground.

OnFocus

t2QSQ‖Deactivate Document

guqXK‖...after another document is brought to the foreground.

OnUnfocus

MvDXG‖Save Document

4ziEe‖...before a document is saved with File - Save or the Save icon, provided that a document name has already been specified.

OnSaveAs

8hHA5‖Document has been saved

rfcxa‖...after a document is saved with File - Save or the Save icon, provided that a document name has already been specified.

OnSaveDone

7FEpD‖Saving of document failed

FnDEp‖Document could not be saved.

OnSaveFailed

VUPBD‖Save Document As

qMrvw‖...before a document is saved under a specified name (with File - Save As, or with File - Save or the Save icon, if a document name has not yet been specified).

OnSaveAs

wacHA‖Document has been saved as

G2CqP‖... after a document was saved under a specified name (with File - Save As, or with File - Save or with the Save icon, if a document name has not yet been specified).

OnSaveAsDone

7BDQa‖'Save As' has failed

FGnZt‖Document could not be saved.

OnSaveAsFailed

9PEDi‖-no UI-

AUk3A‖When the document disk location has changed, for example after a File - Save As action.

OnStorageChanged

n5TCf‖Storing or exporting copy of document

wP2PH‖...before a document is saved with File - Save a Copy, File - Export, File - Export as PDF or the Save icons.

OnCopyTo

ECboz‖Document copy has been created

gF2u2‖...after a document is saved with File - Save a Copy, File - Export, File - Export as PDF or the Save icons.

OnCopyToDone

uAeBw‖Creating of document copy failed

dFCuE‖Document could not be copied or exported.

OnCopyToFailed

qDSzB‖Print document

kDap2‖...after the Print dialog is closed, but before the actual print process begins. This event occurs for each copy printed.

OnPrint

KNASw‖-no UI-

fNkWD‖...after document security settings have changed.

OnModeChanged

5Cfig‖'Modified' status was changed

vVXPg‖Modified state of a document has changed.

OnModifyChanged

po5DD‖Document title changed

KjqSB‖When the document title gets updated.

OnTitleChanged

AkeoE‖Loaded a sub component

Vq5NQ‖...after a database form has been opened.

OnSubComponentOpened

7zuFb‖Closed a sub component

Gzmes‖...after a database form has been closed.

OnSubComponentClosed

KHhEE‖Printing of form letters started

AAYeB‖...before printing form letters using File - Print or Tools - Mail Merge Wizard menus.

OnMailMerge

vDckq‖Printing of form letters finished

Wp5ff‖...after printing of form letters using File - Print or Tools - Mail Merge Wizard menus.

OnMailMergeFinished

RpMCy‖Printing of form fields started

NDjvr‖...before printing form fields.

OnFieldMerge

pMuA3‖Printing of form fields finished

7GYKZ‖...after printing form fields.

OnFieldMergeFinished

esqcH‖Change of the page count

hAoeW‖When the page count changes.

OnPageCountChanged


note

XQXbJ‖Most events relate to documents, except OnStartApp, OnCloseApp, OnCreate and OnLoadFinished that occur at application level. OnSubComponentOpened, and OnSubComponentClosed events are fired by database's forms.


tip

e6gAF‖Writer documents are triggering those specific events: OnLayoutFinished, OnMailMerge, OnMailMergeFinished, OnFieldMerge, OnFieldMergeFinished and OnPageCountChanged.


7xyqi‖Assigning a Macro to an Event

  1. 37TrA‖Choose Tools - Customize and click the Events tab.

  2. AgVEM‖Select whether you want the assignment to be globally valid or just valid in the current document in the Save In listbox.

  3. em5hj‖Select the event from the Event list.

  4. 7Hcqy‖Click Macro and select the macro to be assigned to the selected event.

  5. BMHGD‖Click OK to assign the macro.

  6. jtkJ7‖Click OK to close the dialog.

DzQYQ‖Removing the Assignment of a Macro to an Event

  1. UGGUT‖Choose Tools - Customize and click the Events tab.

  2. BCPRn‖Select whether you want to remove a global assignment or an assignment that is just valid in the current document by selecting the option in the Save In listbox.

  3. 7ZkYK‖Select the event that contains the assignment to be removed from the Event list.

  4. BBaJ6‖Click Remove.

  5. zrhkb‖Click OK to close the dialog.

95hhB‖In addition to assigning macros to events, one can monitor events triggered in LibreOfficeDev documents.