Compartilhar via


Macros.Resume Method

Resumes macro recording if it has been paused. This method should not be used from within a macro.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Syntax

'Declaration
Sub Resume
void Resume()
void Resume()
abstract Resume : unit -> unit
function Resume()

Remarks

To pause macro recording, use Pause. Resume fails if macro recording has not been paused.

Resume should be used only from within add-ins.

If you invoke Resume in an Add-in while not in macro recording mode, the method does nothing and an "Unspecified error" message occurs.

Examples

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 Security

See Also

Reference

Macros Interface

EnvDTE Namespace

Other Resources

Automating Repetitive Actions by Using Macros