イベント駆動マクロについての文書

このセクションでは、スクリプトをアプリケーション、ドキュメント、またはフォームイベントに割り当てる方法について説明します。

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

アプリケーションの開始時

...after a LibreOffice application is started.

OnStartApp

アプリケーション終了時

...LibreOffice アプリケーションを終了する直前。

OnCloseApp

文書作成時

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

OnCreate

新規ドキュメント

...メニュー ファイル → 新規作成 および アイコン 新規作成 により新規ドキュメントを作成した直後。

OnNew

文書の読み込み終了時

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

OnLoadFinished

ドキュメントを開く時

...メニュー ファイル → 開く... および アイコン ファイルを開く によりドキュメントを開いた直後。

OnLoad

文書が閉じられる直前

...ドキュメントを保存する直前。

OnPrepareUnload

ドキュメントを閉じました

...ドキュメントを保存した直後。「ドキュメントの保存時」イベントは、ドキュメントを閉じる際の保存処理で発生することもあるので注意が必要です。

OnUnload

-no UI-

OnLayoutFinished

ビューの作成時

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

OnViewCreated

ビューが閉じられる直前

Document layout is getting removed.

OnPrepareViewClosing

ビューを閉じた時

Document layout is cleared prior to the document closure.

OnViewClosed

ドキュメントをアクティブにした時

...ドキュメントをフォアグラウンドに移動した直後。

OnFocus

ドキュメントを非アクティブにした時

...他のドキュメントをフォアグラウンドに移動した直後。

OnUnfocus

ドキュメントの保存時

...既に名前を付けて保存してあるファイルを、メニュー ファイル → 保存 やアイコン ドキュメントの保存 により再保存する直前。

OnSaveAs

ドキュメントが保存された時

...既に名前を付けて保存してあるファイルを、メニュー ファイル → 保存 やアイコン ドキュメントの保存 により再保存した直後。

OnSaveDone

文書の保存が失敗した時

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

文書を保存もしくはエクスポートした時

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

OnCopyTo

文書のコピーを作った時

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

OnCopyToDone

文書のコピーが失敗した時

Document could not be copied or exported.

OnCopyToFailed

ドキュメントの印刷

...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 state of a document has changed.

OnModifyChanged

文書のタイトルを変更した時

When the document title gets updated.

OnTitleChanged

サブコンポーネントを読み込んだ時

...after a database form has been opened.

OnSubComponentOpened

サブコンポーネントを閉じた時

...after a database form has been closed.

OnSubComponentClosed

フォームレターの印刷開始時

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

OnMailMerge

フォームレターの印刷終了時

...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. OK ボタンを押してマクロを割り当てます。

  6. OK をクリックして、ダイアログを閉じます。

イベントへのマクロ割り当てを解除する

  1. メニューツール → カスタマイズ を選択して、イベントタブをクリックします。

  2. 保存先 リストボックス内のオプションを選択することで、全体の割り当てを解除するか、現在のドキュメント内でのみ有効な割り当てを解除するかどうかを選択します。

  3. 割り当てを解除するイベントを、イベント リストから選択します。

  4. 解除 をクリックします。

  5. OK をクリックして、ダイアログを閉じます。

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

ご支援をお願いします!