Document Event-Driven Macros

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

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.

事件

執行指定的巨集…

routine

Start Application

...after a LibreOffice application is started.

OnStartApp

Close Application

LibreOffice 應用程式終止之前。

OnCloseApp

Document created

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

OnCreate

New Document

透過選擇[檔案] - [開啟新檔]或按一下開啟新檔圖示建立新文件之後。

OnNew

Document loading finished

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

OnLoadFinished

開啟文件

透過選擇[檔案] - [開啟舊檔]或按一下開啟檔案圖示開啟文件之後。

OnLoad

Document is going to be closed

文件關閉之前。

OnPrepareUnload

文件已關閉

文件關閉之後。請注意,在文件關閉之前進行儲存時,也會發生「儲存文件」事件。

OnUnload

-no UI-

OnLayoutFinished

View created

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

OnViewCreated

View is going to be closed

Document layout is getting removed.

OnPrepareViewClosing

View closed

Document layout is cleared prior to the document closure.

OnViewClosed

啟動文件

文件顯示在前景之後。

OnFocus

關閉文件

另一個文件顯示在前景之後。

OnUnfocus

儲存文件

使用[檔案] - [儲存檔案]或按一下儲存文件圖示儲存檔案之前 (倘若已指定檔案名稱)。

OnSaveAs

文件已經儲存

使用[檔案] - [儲存檔案]或按一下儲存文件圖示儲存檔案之後 (倘若已指定檔案名稱)。

OnSaveDone

Saving of document failed

Document could not be saved.

OnSaveFailed

文件另存為

以指定名稱儲存檔案之前 (使用[檔案] - [另存新檔];如果尚未指定檔案名稱,則使用[檔案] - [儲存檔案]或按一下儲存文件圖示)。

OnSaveAs

文件已經儲存為

... 以指定名稱儲存文件之後 (使用[檔案] - [另存新檔];如果尚未指定文件名稱,則使用[檔案] - [儲存檔案]或按一下儲存文件圖示)。

OnSaveAsDone

'Save As' has failed

Document could not be saved.

OnSaveAsFailed

-no UI-

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

OnStorageChanged

Storing or exporting copy of document

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

OnCopyTo

Document copy has been created

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

OnCopyToDone

Creating of document copy failed

Document could not be copied or exported.

OnCopyToFailed

Print document

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

OnPrint

-no UI-

...after document security settings have changed.

OnModeChanged

'Modified' status was changed

Modified state of a document has changed.

OnModifyChanged

Document title changed

When the document title gets updated.

OnTitleChanged

Loaded a sub component

...after a database form has been opened.

OnSubComponentOpened

Closed a sub component

...after a database form has been closed.

OnSubComponentClosed

Printing of form letters started

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

OnMailMerge

Printing of form letters finished

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

OnMailMergeFinished

Printing of form fields started

...before printing form fields.

OnFieldMerge

Printing of form fields finished

...after printing form fields.

OnFieldMergeFinished

頁數的變更

When the page count changes.

OnPageCountChanged


note

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

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


將巨集指定給事件

  1. 選擇 [工具] - [調整],然後按一下 [事件] 標籤。

  2. [儲存位置] 清單方塊中,選取要使指定全域有效或僅對目前文件有效。

  3. [事件]清單中選取事件。

  4. 按一下 [巨集],並選取要指定給所選事件的巨集。

  5. 按一下 [確定] 可指定巨集。

  6. 按一下[確定]以關閉對話方塊。

移除為事件指定的巨集

  1. 選擇 [工具] - [調整],然後按一下 [事件] 標籤。

  2. 透過選取 [儲存位置] 清單方塊中的選項,選取要移除全域指定或僅移除對目前文件有效的指定。

  3. [事件]清單中選取包含所要移除指定的事件。

  4. 按一下[取消]

  5. 按一下[確定]以關閉對話方塊。

In addition to assigning macros to events, one can monitor events triggered in LibreOffice documents.

Please support us!