Microsoft KB Archive/833897

= The OnMacrosRuntimeReset event does not fire when you load a macro in Visual Studio 2005 or in Visual Studio .NET =

Article ID: 833897

Article Last Modified on 11/27/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition

-





SYMPTOMS
In Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET, the OnMacrosRuntimeReset event does not fire when you load a macro. The OnMacrosRuntimeReset event does fire when you unload the macro.



STATUS
This behavior is by design.



Steps to reproduce the behavior
 Start Visual Studio 2005 or Visual Studio .NET. On the View menu, point to Other Windows, and then click Macro Explorer. In the Macro Explorer window, expand MyMacros, right-click the Module1 module, and then click Edit. In the Project Explorer pane, double-click on the EnvironmentEvents.vb file.  Replace the code in the EnvironmentEvents.vb file with the following code: Option Strict Off Option Explicit Off Imports EnvDTE Imports System.Diagnostics Imports System.ContextStaticAttribute

Public Module EnvironmentEvents Public WithEvents TextEditorEvents As EnvDTE.TextEditorEvents

Public Sub DTEEvents_OnMacrosRuntimeReset Handles DTEEvents.OnMacrosRuntimeReset TextEditorEvents = DTE.Events.TextEditorEvents MsgBox(&quot;Hello!&quot;) End Sub 'Automatically generated code, do not modify 'Event Sources Begin  Public WithEvents DTEEvents As EnvDTE.DTEEvents  Public WithEvents DocumentEvents As EnvDTE.DocumentEvents <System.ContextStaticAttribute> Public WithEvents WindowEvents As EnvDTE.WindowEvents <System.ContextStaticAttribute> Public WithEvents TaskListEvents As EnvDTE.TaskListEvents <System.ContextStaticAttribute> Public WithEvents FindEvents As EnvDTE.FindEvents <System.ContextStaticAttribute> Public WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents <System.ContextStaticAttribute> Public WithEvents SelectionEvents As EnvDTE.SelectionEvents <System.ContextStaticAttribute> Public WithEvents BuildEvents As EnvDTE.BuildEvents <System.ContextStaticAttribute> Public WithEvents SolutionEvents As EnvDTE.SolutionEvents <System.ContextStaticAttribute> Public WithEvents SolutionItemsEvents As EnvDTE.ProjectItemsEvents <System.ContextStaticAttribute> Public WithEvents MiscFilesEvents As EnvDTE.ProjectItemsEvents <System.ContextStaticAttribute> Public WithEvents DebuggerEvents As EnvDTE.DebuggerEvents 'Event Sources End 'End of automatically generated code End Module </li> Save the MyMacros macro project.</li> In the Macro Explorer pane, right-click MyMacros project, and then click Unload Macro Project.
 * 1) Region &quot;Automatically generated code, do not modify&quot;
 * 1) End Region

Note If the MyMacros project is set as the recording project, create a new macro project, and then set it as the recording project.</li> In the Macro Explorer pane, right-click Macros, and then click Load Macro Project to load the MyMacros project. A warning message is shown.</li> In the Warning message box, click Enable event handling code, and then click OK.</li> Perform step 7. The OnMacrosRuntimeReset event is fired two times. Click OK two times to close the two message boxes that display.</li> Perform step 8 and step 9. Notice that the OnMacrosRuntimeReset event is not fired.</li></ol>

<div class="references_section">