Isi
Indeks 🔎︎

# 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.

Peristiwa | Makro yang ditetapkan dieksekusi... | routine
--- | --- | ---
Start Application | ...after a LibreOfficeDev application is started. | OnStartApp
Close Application | ...sebelum aplikasi LibreOfficeDev dihentikan. | 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 | ...setelah dokumen baru dibuat dengan Berkas - Baru atau dengan ikon Baru. | OnNew
Document loading finished | ...before a document is opened with File - Open or with the Open icon. | OnLoadFinished
Membuka Dokumen | ...setelah dokumen dibuka dengan Berkas - Buka atau dengan ikon Buka. | OnLoad
Document is going to be closed | ... sebelum dokumen ditutup. | OnPrepareUnload
Dokumen ditutup | ...setelah dokumen ditutup. Perhatikan bahwa kejadian "Simpan Dokumen" juga dapat terjadi ketika dokumen disimpan sebelum ditutup. | 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
Aktifasi Dokumen | ... usai dokumen dibawa ke permukaan. | OnFocus
Deaktifasi Dokumen | ... usai dokumen dibawa ke bawah permukaan. | OnUnfocus
Simpan Dokumen | ...sebelum sebuah dokumen disimpan dengan Berkas - Simpan atau Simpan ikon, asalkan nama dokumen telah ditentukan. | OnSaveAs
Dokumen telah disimpan | ...setelah sebuah dokumen disimpan dengan Berkas - Simpan atau Simpan ikon, asalkan nama dokumen telah ditentukan. | OnSaveDone
Saving of document failed | Document could not be saved. | OnSaveFailed
Simpan Dokumen Sebagai | ...sebelum dokumen disimpan dengan nama spesifik (dengan Berkas - Simpan Sebagai, atau dengan Berkas - Simpan atau ikon Simpan, jika nama dokumen belum ditentukan). | OnSaveAs
Dokumen telah disimpan sebagai | ... setelah sebuah dokumen disimpan dengan nama spesifik (dengan Berkas - Simpan Sebagai, atau dengan Berkas - Simpan atau dengan ikon Simpan, jika nama dokumen belum ditentukan). | 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
Ganti jumlah halaman | When the page count changes. | OnPageCountChanged

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.

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

## Menetapkan Makro ke Kejadian

1. Pilih Alat-alat - Kostum dan klik Events tab.

2. Pilih apakah Anda ingin tugas tersebut berlaku secara global atau hanya berlaku dalam dokumen saat ini di Simpan di daftar kotak.

3. Pilih kejadian dari Kejadian daftar.

4. Klik Makro dan pilih makro yang akan ditugaskan ke kejadian yang dipilih.

5. Klik Oke untuk menerima makro.

6. Klik Oke untuk menutup dialog.

## Menghapus Penugasan Makro ke kejadian

1. Pilih Alat - Sesuaikan dan klikKejadian tab.

2. Pilih apakah Anda ingin menghapus penugasan global atau tugas yang hanya valid dalam dokumen saat ini dengan memilih opsi diSimpan dalamdaftar kotak.

3. Pilih acara yang berisi tugas yang akan dihapus dariKejadiandaftar.

4. Klik Buang.

5. Klik Oke untuk menutup dialog.

Topik Terkait

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