Macro Recording and Running Issues
The following is a list of issues you can encounter when recording and running macros in Visual Studio.
Macro Recording Issues
When you record a macro, the environment tracks the elements you alter and the keys you press and generates macro code based on that input. Not every UI element or event, however, can be recorded. Macro recording is limited to:
Text/Code editors, such as the Visual Studio code editor.
Visual Studio commands and menu items. By default, Visual Studio records command invocations by name if the commands themselves do not emit code against an automation model particular to the UI feature.
Common tree view tool windows, such as Solution Explorer.
The Add Item dialog box.
The Find and Replace dialog boxes.
General window events, such as activating or closing a window.
If, while recording a macro, you happen to manipulate an element of the environment that does not generate macro code, and did not go through a standard environment command — such as editing in an edit control in a dialog box — you will have a recording gap in your macro, and thus, the macro will not work as expected.
If this happens, you can manually edit the macro and, in most cases, create the necessary code yourself. For details about how to do this, see How to: Edit and Programmatically Create Macros.
Some commands are disabled while recording a macro, such as immediate search (ISearch), and the user model of the recording project and Recording module.
When you record a macro in the Code/Text editor, no mouse clicks or other mouse events are recorded.
Note
VS Macros do not currently support Windows Forms.
Macro Running Issues
You cannot run a macro if its parent project cannot build, such as if another macro in the project contains errors.
Macros maintain the value of their variables between executions of the macro, but not between sessions of the integrated development environment (IDE). For example, if a particular macro increments a counter each time the macro is executed, that value is retained between invocations of the macro, but the value is lost if the Visual Studio IDE is closed.
When you run a macro from Macro Explorer, the environment identifies the last activated window as the last window that was opened immediately prior to opening Macro Explorer, and the macro is run as if that window had focus. This prevents problems with Macro Explorer's window itself inadvertently getting the focus in your macro's operation.
See Also
Concepts
Automating Repetitive Actions by Using Macros
Macros Security and Sharing Issues