在 LibreOffice 中指定程式檔

您可以將自訂的程式檔 (巨集) 指定給 LibreOffice 中的功能表項目、圖示、對話控制項以及事件。

LibreOffice 支援下列的程式檔語言:

  1. LibreOffice Basic

  2. JavaScript

  3. BeanShell (Java)

  4. Python

In addition, developers can use high-level languages, for example Java programming language, to control LibreOffice externally. The API reference is online at api.libreoffice.org.

將程式檔指定給新的功能表條目

  1. 選擇 [工具] - [自訂],然後按一下 [功能表] 標籤。

  2. 按一下 [新增指令]

  3. In the Category list box, scroll down and open the "Application Macros" entry.

  4. You see entries for "Application Macros" (scripts in the share directory of your LibreOffice installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.

  5. 開啟任何程式檔語言條目以查看可用的程式碼。選取程式檔。

  6. 程序檔功能清單會出現在 [指令] 清單方塊中。請選取一個功能。

  7. 按一下 [增加] 可建立新的功能表指定。新的功能表條目會顯示在 [條目] 清單方塊中。

指定組合鍵的程式檔

  1. 選擇 [工具] - [自訂] - [鍵盤]

  2. In the Category list box, scroll down and open the "Application Macros" entry.

  3. You see entries for "Application Macros" (scripts in the share directory of your LibreOffice installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.

  4. 開啟任何程式檔語言條目以查看可用的程式檔。選取任何程式檔。

  5. 程序檔功能清單會出現在 [指令] 清單方塊中。請選取任何功能。

  6. 按一下 LibreOffice 或 Writer 的選項按鈕 (或目前開啟的應用程式)。

    選取選項按鈕,將新的組合鍵範圍設定為可用於所有 LibreOffice,或設定為僅可用於目前模組的文件中。

  7. Select a key combination from the Shortcut keys list box and click Assign.

指定事件的程式檔

  1. 選擇 [工具] - [自訂] - [事件]

  2. 按一下 [巨集] 按鈕。

  3. In the Library list box, scroll down and open the "Application Macros" entry.

  4. You see entries for "Application Macros" (scripts in the share directory of your LibreOffice installation), "My Macros" (scripts in the user directory), and the current document. Open any one of them to see the supported scripting languages.

  5. 開啟任何程式檔語言條目以查看可用的程式檔。選取任何程式檔。

  6. 程序檔功能清單會出現在 [指定的動作] 清單方塊中。請選取任何功能。

  7. 選取以儲存在 LibreOffice 或目前的文件中。

    如此會將新的事件指定範圍設定為可用於所有 LibreOffice,或設定為僅可用於目前模組的文件中。

  8. 從清單中選取一個事件,然後按一下 [確定]

指定程式碼給內嵌物件的事件

  1. 在文件中選取內嵌物件,例如一個圖表。

  2. Choose Format - Frame and Object - Properties - Macro.

  3. [巨集] 清單方塊中,開啟 LibreOffice 程式檔條目。

  4. 您會看見共用條目 (您 LibreOffice 安裝的共用目錄中的程式檔)、使用者 (使用者目錄中的程式檔) 以及目前的文件。開啟任何其中一個以查看支援的程式檔語言。

  5. 開啟任何程式檔語言條目以查看可用的程式檔。選取任何程式檔。

  6. 程式檔功能清單會出現在 [現有巨集位置] 清單方塊中。選取任何功能。

  7. 從清單中選取一個事件,然後按一下 [確定]

指定超連結的程式檔

  1. 將游標定位在超連結的內部

  2. 選擇 [插入] - [超連結]

  3. 按一下 [事件] 按鈕。

  4. 如同上述進行選取與指定。

指定圖形的程式檔

  1. 選取文件中的圖形。

  2. Choose Format - Image - Properties - Macro.

  3. 如同上述進行選取與指定。

指定表單控制項的程式檔

  1. 插入表單控制項,例如按鈕:開啟 [控制項] 工具列,按一下按鈕圖示,在您的文件上拖曳放大按鈕。

  2. 針對選取的表單控制項,按一下 [控制項] 工具列上的 [控制項]

  3. 按一下 [特性] 對話方塊的 [事件] 標籤。

  4. 按一下其中一個 [...] 按鈕以開啟一個對話方塊,您可以在此對話方塊中將程式檔指定至選取的事件。

將程式檔指定至 LibreOffice Basic 對話方塊中的控制項

  1. 開啟 LibreOffice Basic 對話方塊編輯器,然後建立包含控制項的對話方塊。

  2. 在控制項上按一下滑鼠右鍵,並選擇 [特性]

  3. 按一下 [特性] 對話方塊的 [事件] 標籤。

  4. 按一下其中一個 [...] 按鈕以開啟一個對話方塊,您可以在此對話方塊中將程式檔指定至選取的事件。

Please support us!