Recording Macros

Home Page (Macros)OverviewHow Do I TopicsFAQReference

You can record a macro in two ways. If you want to develop a complex macro that you can refine by editing the VBScript macro file, regular macro recording provides the interface to do so. The Quick Macro options by-pass this interface, enabling you to quickly record your actions without having to name a macro, provide a description for it, or review the resulting macro file. This also saves you some keystrokes whenever you want to run the Quick macro, as it remains available from the menu ¯ even if you close and reopen Visual C++ ¯ until you record another Quick macro.

You can also write a VBScript macro by hand.

During macro recording, you can temporarily pause to do something else. For example, you can pause to prepare for the next action. While you pause, the recorder does not track your keystrokes. When you are ready, you can resume recording where you stopped.

Note   The recorder cannot record mouse actions when selecting text or moving the insertion point. You must use the keyboard to record these actions. However, you can use the mouse to click commands and options. The recorder does not always convert keystrokes into commands. If you are recording a named macro (not a Quick macro), examine the macro carefully when you stop recording to ensure it is complete. If you find something missing, add the appropriate code.

What do you want to do?

Record a Quick macro

Record a named macro that I can save and edit

To record a quick macro

  1. On the Tools menu, click Record Quick Macro.

  2. Perform the actions that you want to record.

  3. You can use the Pause button on the macro recorder toolbar as a toggle to temporarily interrupt and resume recording.

  4. When you have finished, click the Stop button on the macro recorder toolbar.

  5. To play back the macro, click Play Quick Macro on the Tools menu.

  6. This temporary macro remains available until you record another Quick macro, which writes over any existing Quick macro.

To record a named macro that you can save and edit

  1. On the Tools menu, click Macro.

  2. To add the macro to a new macro file, click the Options button, click the NewFile button, and then enter the file name in the MacroFile box.

    -or-

    To add the macro to an existing file, select the file name from the MacroFile box. If the name is not there, first install the file, then select it in the MacroFile box.

  3. In the MacroName box, enter a unique name for the macro.

  4. Click the Record button.

    Note   You cannot record a macro that already exists or record to a file that is read-only.

  5. In the AddMacro box, enter a description of the macro, and then click OK.

  6. Perform the actions you want to record.

  7. To pause the recording, click the Pause button.

    (To resume recording, click the Pause button again.)

  8. To stop recording, click the Stop button.

    When recording stops, the selected macro file opens with the insertion point in the Sub block of the newly recorded macro.

If the recorder cannot match a VBScript command to the actual command you carry out, the recorder inserts an ExecuteCommand call to carry out the command. However, if the recorder substitutes ExecuteCommand for a command that causes a dialog box to display, when you run the macro, the dialog box will appear, but no user input will display.