Contents

# 管理程式庫和模組

## Basic Libraries Containers

LibreOffice Basic libraries can be stored in 3 different containers:

- Application Macros: libraries stored in this container are available for all users of the computer and are managed by the computer administrator. The container is located in the LibreOffice installation directory.

- My Macros: libraries stored in this container are available to all documents of your user. The container is located in the user profile area and is not accessible by another user.

- Document: libraries stored in the document container are only available for the document and are accessible only when the document is open. You cannot access macros of a document from another document.

To access macros stored in libraries of Application Macros or My Macros from another container, including the document container, use the GlobalScope specifier.

## 管理程式庫

### 建立新的程式庫

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下[程式庫]標籤。

3. Select to where you want to attach the library in the Location list. If you select Application Macros & Dialogs, the library will belong to the LibreOffice application and will be available for all documents. If you select a document the library will be attached to this document and only available from there.

4. 按一下[新增]，並插入名稱來建立新的程式庫。

### 匯入程式庫

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下[程式庫]標籤。

3. Select to where you want to import the library in the Location list. If you select Application Macros & Dialogs, the library will belong to the LibreOffice application and will be available for all documents. If you select a document the library will be imported to this document and only available from there.

4. 按一下[新增]，並選取要新增的外部程式庫。

5. 在[新增程式庫]對話方塊中選取所有要新增的程式庫。該對話方塊中會顯示所選檔案中包含的所有程式庫。

6. 如果要將程式庫作為參照插入，請核取[當作參照插入 (唯讀)]方塊。在 Basic IDE 中，唯讀程式庫具有程式庫的全部功能，但無法進行修改。

7. 如果要覆寫同名的現有程式庫，請核取[代替顯有程式庫]方塊。

8. 按一下[確定]以新增程式庫。

### 匯出程式庫

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下[程式庫]標籤。

3. In the Location list you specify where your library is stored. Select the library that you want to export. Note that you cannot export the Standard library.

4. Click Export...

5. Choose whether you want to export the library as an extension or as a BASIC library.

6. 按一下[取消]。

7. Select where you want your library exported.

8. 按一下[確定]以新增程式庫。

### 刪除程式庫

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下[程式庫]標籤。

3. 從清單中選取要刪除的程式庫。

4. 按一下[刪除]。

- 備註：一旦刪除了某個程式庫，現有的所有模組和對應的 SUB 和 FUNCTION 將被永久刪除。

- 您無法刪除名為「Standard」的標準程式庫。

- 如果刪除的是當作參照插入的程式庫，則僅刪除參照而不會刪除該程式庫。

## 管理模組和對話方塊

### 建立新的模組或對話方塊

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下 [模組] 標籤或 [對話方塊] 標籤。

3. 選取要向其中插入模組的程式庫，並按一下 [新增]。

4. 輸入模組或對話方塊的名稱，然後按一下[確定]。

### 重新命名模組或對話方塊

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按兩次要重新命名的模組，兩次之間要暫停一下。輸入新的名稱。

   在 Basic IDE 中，在螢幕底部標籤中的模組名稱或對話方塊名稱上按一下滑鼠右鍵，選擇 [重新命名]，然後鍵入新名稱。

3. 按 ENTER 鍵確認變更。

### 刪除模組或對話方塊

1. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

2. 按一下 [模組] 標籤或 [對話方塊] 標籤。

3. 選取要從清單中刪除的模組或對話方塊。如果需要，可以透過按兩下該項目來展開子項目。

4. 按一下[刪除]。

刪除模組將永久刪除該模組中現有的所有程序和函式。

## 管理物件和文件樣式之間的專案

### 在文件、文件樣式和應用程式之間移動或複製模組。

1. 開啟所有要在其間移動或複製模組或對話方塊的文件或文件樣式。

2. Choose Tools - Macros - Organize Macros - Basic and click Organizer or click the Select Module icon in the Basic IDE to open the Macro Organizer dialog.

3. 若要將模組或對話方塊移至另一個文件，請按一下清單中相對應的物件，然後將其拖曳至所需的位置。拖曳時，會出現水平線指出目前物件的目標位置。拖曳時按住 Command Ctrl 鍵，則可複製物件而非移動物件。