Recording a Macro
Each macro is contained within a macro project. You can have one macro or multiple macros in a macro project. When you record a macro, you must set Recording Project in the Macro Explorer. This is done by right-clicking on a macro project name in the Macro Explorer and selecting Set As Recording Project from the contextual menu. The project name in bold in the Macro Explorer is always the current recording project.
After you record a macro, it's saved as TemporaryMacro in the Macro Explorer. At this point, you must rename the macro to something other then TemporaryMacro or it will be recorded over the next time a macro is recorded.
To record your first macro, double-click on the default form1 in the Windows Forms Designer to get the Code Editor.
Next, select Record TemporaryMacro from the Tools, Macro menu. At this point, the recording of your new macro has started. You''ll notice the Macro Recording toolbar pops up in the IDE, as Figure 16.3 shows.
Figure 16.3. The Macro Recording toolbar.

From the Macro Recording toolbar, you can pause, stop, and cancel the recording process.
In the code window, you''re going to add some code that all methods should have: a Try/Catch block for correct error handling. Add the code in Listing 16.1 to the Form_Load event of the default form1.
Listing 16.1 Adding the Try/Catch Block to the Form_Load Event

Try
Catch ex as Exception
MessageBox.Show(ex.Message)
Finally
End Try

try
{
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
After you''ve typed in the code, click the Stop button on the Macro Recording toolbar. The macro has now been recorded and stored as TemporaryMacro in the Current Recording module within the Macro Explorer as shown in Figure 16.4.
Figure 16.4. The TemporaryMacro after recording.

Now that the macro is recorded, you must rename the TemporaryMacro to something meaningful. In the Macro Explorer, right-click on TemporaryMacro and select Rename from the contextual menu. Rename the macro to TryCatchBlock, as Figure 16.5 shows.
Figure 16.5. Renaming TemporaryMacro to TryCatchBlock.

Now you can test your macro.
First, delete the Try/Catch block code that you just added in the code window.
Next, from the Macro Explorer, double-click the TryCatchBlock macro. Now watch as the code appears like magic in the Code Editor. You can also right-click on the macro name and select Run from the contextual menu to run the macro.
You''ve just recorded your first macro. As you can see, it isn''t too difficult. The next step is to examine the code that was recorded in the Macros IDE.