Applies To
Application Object.
Description
Records code if the macro recorder is on.
Syntax
object.RecordMacro(basicCode, xlmCode)
object
Required. The Application object.
basicCode
Optional. A string that specifies the Visual Basic code that will be recorded if the macro recorder is recording into a Visual Basic module. The string will be recorded on one line. If the string contains a carriage return (ASCII character 10, or Chr$(10) in code), it will be recorded on more than one line.
xlmCode
Optional. A string that specifies the formula that will be recorded if the macro recorder is recording into a Microsoft Excel version 4.0 macro sheet. The string will be recorded into one cell. If the string does not begin with an equal sign, a comment is recorded.
Remarks
The RecordMacro method cannot record into the active module (the module in which the RecordMacro method exists).
If basicCode is omitted, and the application is recording into Visual Basic, Microsoft Excel will record a suitable Application.Run statement.
If xlmCode is omitted, and the application is recording into Microsoft Excel version 4.0, Microsoft Excel will record a suitable RUN macro function.
To prevent recording (for example, if the user cancels your dialog box), call this function with two empty strings.
Example
This example records either Visual Basic code or an XLM formula.
Application.RecordMacro basicCode:="Application.Run ""MySub"" ", _ xlmCode:="=MySub()"