巨集是在程式碼模組中的任意公用副程式。 函數或私人副程式都不能成為巨集,而且巨集不得位於類別或表單模組中。
若要建立新的巨集
在 Outlook 中,於 Microsoft Office Fluent 功能區的 [開發人員] 索引標籤上,按一下 Visual Basic。
In the Project window, double-click the module you want to contain the macro.
On the Insert menu, click Procedure.
In the Name box, type a name for the macro. 名稱不能包含空格。
按一下 [確定]。 The template for the macro subroutine appears in the code module window.
輸入您要在副程式的主體中執行的程式碼。
如需使用 [Visual Basic 編輯器] 的詳細資訊,請參閱 [Visual Basic 編輯器說明]。 一旦建立巨集之後,您便能夠建立會在按一下時執行巨集的功能表項目或工具列按鈕。
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。