Compartir a través de


Macros.EmitMacroCode (Método)

Escribe la línea de código en la macro que se está grabando. Este método no debe usarse dentro de una macro.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

'Declaración
Sub EmitMacroCode ( _
    Code As String _
)
void EmitMacroCode(
    string Code
)
void EmitMacroCode(
    String^ Code
)
abstract EmitMacroCode : 
        Code:string -> unit
function EmitMacroCode(
    Code : String
)

Parámetros

  • Code
    Tipo: String

    Obligatorio. Línea de código que se va a agregar a la macro.

Comentarios

Es posible utilizar EmitMacroCode para compilar macros o para agregar código a macros existentes.

Este método produce un error si el entorno no está en modo de grabación de macros. EmitMacroCode sólo debe utilizarse dentro de complementos.

Ejemplos

public void CodeExample(DTE2 dte, AddIn addin)
{
    // INSTRUCTIONS: Run this code, open a solution, start
    // recording a macro, then connect the add-in containing this code.
    try
    {
        Macros mac = dte.Macros;
        if (mac.IsRecording)
        {
            mac.Pause();
            if (!mac.IsRecording)
                mac.Resume();
            mac.EmitMacroCode("rem Code added by the EmitMacroCode method");
            // Demonstrate these two properties return the same reference.
            bool test = mac.DTE.Equals(mac.Parent);
            if (test) MessageBox.Show("The DTE and Parent property refer to the same object.");
            else MessageBox.Show("The DTE and Parent property do not refer to the same object.");
        }
        else MessageBox.Show("Start a macro recording session and reconnect addin");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Seguridad de .NET Framework

Vea también

Referencia

Macros Interfaz

EnvDTE (Espacio de nombres)

Otros recursos

Automating Repetitive Actions by Using Macros