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.

Sự kiện

Một vĩ lệnh đã gán được thực hiện...

routine

Start Application

...after a LibreOffice application is started.

OnStartApp

Close Application

...trước khi kết thúc một ứng dụng 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

...sau khi một tài liệu mới được tạo bằng lệnh Tập tin > Mới hoặc bằng biểu tượng Mới.

OnNew

Document loading finished

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

OnLoadFinished

Mở tài liệu

...sau khi một tài liệu được mở bằng lệnh Tập tin > Mở hoặc bằng biểu tượng Mở.

OnLoad

Document is going to be closed

...trước khi đóng tài liệu.

OnPrepareUnload

Đóng tài liệu

...sau khi đóng tài liệu. Lưu ý rằng sự kiện "Lưu tài liệu" cũng có thể xảy ra khi tài liệu được lưu trước khi đóng.

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

Kích hoạt tài liệu

...sau khi một tài liệu được nâng lên trên.

OnFocus

Khử hoạt tài liệu

...sau khi tài liệu khác được nâng lên trên.

OnUnfocus

Lưu tài liệu

...trước khi một tài liệu được lưu bằng lệnh Tập tin > Lưu hoặc bằng biểu tượng Lưu, miễn là đã xác định một tên cho tài liệu.

OnSaveAs

Tài liệu đã được lưu

...sau khi một tài liệu được lưu bằng lệnh Tập tin > Lưu hoặc biểu tượng Lưu, miễn là đã xác định một tên cho tài liệu.

OnSaveDone

Saving of document failed

Document could not be saved.

OnSaveFailed

Lưu mới tài liệu

...trước khi một tài liệu được lưu dưới một tên cụ thể (dùng lệnh Tập tin > Lưu mới, hoặc dùng lệnh Tập tin > Lưu hoặc biểu tượng Lưu nếu chưa ghi rõ tên tài liệu).

OnSaveAs

Tài liệu đã được lưu dưới dạng

...sau khi một tài liệu được lưu với một tên cụ thể (dùng lệnh Tập tin > Lưu mới, hoặc dùng lệnh Tập tin > Lưu hoặc biểu tượng Lưu nếu chưa ghi rõ tên tài liệu).

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

Hiệu đếm trang

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.


Gán một vĩ lệnh cho một sự kiện

  1. Chọn mục trình đơn Công cụ > Tùy biến, sau đó nhấn vào phiếu Sự kiện.

  2. Trong hộp liệt kê Lưu vào, chọn nếu bạn muốn sự gán này là hợp lệ toàn cục hoặc chỉ hợp lệ trong tài liệu hiện tại.

  3. Chọn sự kiện trong danh sách các Sự kiện.

  4. Nhấn vào nút Vĩ lệnh, sau đó chọn vĩ lệnh cần gán cho sự kiện đã chọn.

  5. Nhấn vào nút OK để gán vĩ lệnh.

  6. Nhấn vào nút OK để đóng hộp thoại.

Gỡ bỏ phép gán vĩ lệnh cho một sự kiện

  1. Chọn mục trình đơn Công cụ > Tùy biến, sau đó nhấn vào phiếu Sự kiện.

  2. Chọn nếu bạn muốn gỡ bỏ một sự gán toàn cục hoặc một sự gán chỉ hợp lệ trong tài liệu hiện tại, bằng cách bật tùy chọn đó trong hộp liệt kê Lưu vào.

  3. Chọn sự kiện có phép gán cần gỡ bỏ trong danh sách các sự kiện.

  4. Nhấn vào nút Bỏ.

  5. Nhấn vào nút OK để đóng hộp thoại.

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

Please support us!