Writing a Macro Manually
Choose Macro from the Tools menu.
Choose Options, and then choose New File to add the macro to a new macro file.
Type a name and a description for the file, and then choose OK.
- or -
Select the file name in the MacroFile box to add the macro to an existing file.
If the file name is not in the list, install the file, and then select it in the MacroFile box.
Type a new name for the macro in the Macro Name box.
Choose Edit.
You cannot create a new macro in a read-only file, but you can browse an existing macro in a read-only file.
Type a description of the macro in the AddMacro dialog box, and then choose OK.
The macro file opens and a SUB block is created for the new macro at the end of the file.
The following code example shows what the SUB block would look like for a macro named MyMacro.
Sub MyMacro() 'Description: The macro description goes here. 'TODO: Insert the macro code here. End Sub
Declare variables that are used in a macro. You declare variables by using the VBScript DIM statement. To be reminded to declare variables before using them, add the line OPTION EXPLICIT to the beginning of each macro file.
See Also
Last updated on Friday, October 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.