Share via


Macros.EmitMacroCode 메서드

기록 중인 매크로에 코드 줄을 씁니다. 매크로 내에서는 이 메서드를 사용할 수 없습니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub EmitMacroCode ( _
    Code As String _
)
void EmitMacroCode(
    string Code
)
void EmitMacroCode(
    String^ Code
)
abstract EmitMacroCode : 
        Code:string -> unit
function EmitMacroCode(
    Code : String
)

매개 변수

  • Code
    형식: String

    필수입니다. 매크로에 추가할 코드 줄입니다.

설명

EmitMacroCode를 사용하여 매크로를 빌드하거나 기존 매크로에 코드를 추가할 수 있습니다.

환경이 매크로 기록 모드로 설정되어 있지 않으면 이 메서드가 실패합니다. EmitMacroCode은 추가 기능에서만 사용할 수 있습니다.

예제

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);
    }
}

.NET Framework 보안

참고 항목

참조

Macros 인터페이스

EnvDTE 네임스페이스

기타 리소스

Automating Repetitive Actions by Using Macros