This documentation is archived and is not being maintained.

Application.MacroOptions Method

Office 2007
Corresponds to options in the Macro Options dialog box. You can also use this method to display a user defined function (UDF) in a built-in or new category within the Insert Function dialog box.

Syntax

expression.MacroOptions(Macro, Description, HasMenu, MenuText, HasShortcutKey, ShortcutKey, Category, StatusBar, HelpContextID, HelpFile)

expression   A variable that represents an Application object.

Parameters

NameRequired/OptionalData TypeDescription
MacroOptionalVariantThe macro name or the name of a user defined function (UDF).
DescriptionOptionalVariantThe macro description.
HasMenuOptionalVariantThis argument is ignored.
MenuTextOptionalVariantThis argument is ignored.
HasShortcutKeyOptionalVariantTrue to assign a shortcut key to the macro (ShortcutKey must also be specified). If this argument is False, no shortcut key is assigned to the macro. If the macro already has a shortcut key, setting this argument to False removes the shortcut key. The default value is False.
ShortcutKeyOptionalVariantRequired if HasShortcutKey is True; ignored otherwise. The shortcut key.
CategoryOptionalVariantAn integer that specifies an existing macro function category (Financial, Date & Time, or User Defined, for example). See the remarks section to determine the integers that are mapped to the built-in categories. You can also specify a string for a custom category. If you provide a string it will be treated as the category name that is displayed in the Insert Function dialog box. If the category name has never been used, a new category is defined with that name. If you use a category name that is that same a built-in name, Excel will map the user defined function to that built-in category.
StatusBarOptionalVariantThe status bar text for the macro.
HelpContextIDOptionalVariantAn integer that specifies the context ID for the Help topic assigned to the macro.
HelpFileOptionalVariantThe name of the Help file that contains the Help topic defined by HelpContextId.

Remarks

The following table lists which integers are mapped to the built-in categories that can be used in the Category parameter.

IntegerCategory
1Financial
2Date & Time
3Math & Trig
4Statistical
5Lookup & Reference
6Database
7Text
8Logical
9Information
10Commands
11Customizing
12Macro Control
13DDE/External
14User Defined
15First custom category
16Second custom category
17Third custom category
18Fourth custom category
19Fifth custom category
20Sixth custom category
21Seventh custom category
22Eighth custom category
23Ninth custom category
24Tenth custom category
25Eleventh custom category
26Twelfth custom category
27Thirteenth custom category
28Fourteenth custom category
29Fifteenth custom category
30Sixteenth custom category
31Seventeenth custom category
32Eighteenth custom category

Example

This example adds a user-defined macro called "TestMacro" to a custom category named "My Custom Category". After you run this example, you should see "My Custom Category" which contains the "TestMacro" user-defined function in the Or select a category drop-down list in the Insert Function dialog box.

Visual Basic for Applications
Function TestMacro()
    MsgBox ActiveWorkbook.Name
End Function

Sub AddUDFToCustomCategory()
    Application.MacroOptions Macro:="TestMacro", Category:="My Custom Category"
End Sub



Show: