Microsoft KB Archive/840922

= Macro projects are saved when you run or build a project in Visual Studio 2005 or in Visual Studio .NET =

Article ID: 840922

Article Last Modified on 11/16/2007

-

APPLIES TO


 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 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, when you open the Microsoft Visual Studio Macros editor, you may notice that the changes that you made earlier to a macro project are saved although you did not explicitly save the changes.



CAUSE
This behavior occurs because the Save changes to open documents only option is selected. This behavior is the default behavior.

Note The Save changes to open documents only option is located under Build and Run Options in the Options dialog box in Visual Studio 2005 or in Visual Studio .NET.



WORKAROUND
To work around this behavior, follow these steps:
 * 1) Start Visual Studio 2005 or Visual Studio .NET.
 * 2) On the Tools menu, click Options. The Options dialog box appears.
 * 3) Double-click Environment, and then click Projects and Solutions.
 * 4) Under Build and Run Options in the right pane of the Options dialog box, select Prompt to save changes to open documents or select Don't save changes to open documents.
 * 5) Click OK.
 * 6) On the File menu, click Exit to quit Visual Studio 2005 or Visual Studio .NET. The Save changes to the following items dialog box appears.
 * 7) Do one of the following:
 * 8) * If you want to save the macro that you created, you click Yes.
 * 9) * If you want to exit Visual Studio 2005 or Visual Studio .NET without saving the macro that you created, you click No.



Steps to reproduce the behavior
 Start Visual Studio 2005 or Visual Studio .NET. On the File menu, point to New, and then click Project. The New Project dialog box appears. Under Project Types, click Visual Basic Projects.

Note In Visual Studio 2005, Visual Basic Projects is changed to Visual Basic. Under Templates, click Console Application. Click OK. By default, a module that is named Module1.vb is added to the ConsoleApplication1 project.  In the Module1 module, replace the existing code with the following code: Module Module1

Sub Main Console.WriteLine(&quot;Start Testing&quot;) Console.ReadLine End Sub

End Module </li> On the Tools menu, point to Macros, and then click Macros IDE. The Microsoft Visual Studio Macros editor appears.</li> On the View menu, click Project Explorer.</li> In Project Explorer, expand MyMacros, and then double-click Module1. The code view of the Module1 module appears.</li>  In Module1 module, replace the existing code with the following code: Imports EnvDTE Imports System.Diagnostics

Public Module Module1 Sub Test Dim a As Integer Dim b As Integer Dim c As Integer c = a + b    End Sub End Module </li> Switch to the instance of Visual Studio 2005 or of Visual Studio .NET where the ConsoleApplication1 project is open.</li> On the Build menu, click Build Solution.</li> On the File menu, click Exit to quit Visual Studio 2005 or Visual Studio .NET. Notice that the Microsoft Visual Studio editor closes also.</li> Start Visual Studio 2005 or Visual Studio .NET.</li> Open the Microsoft Visual Studio Macros editor. Notice that the changes that you made to the macro in step 10 exist. Also, notice that the changes exist in the new Microsoft Visual Studio Macros editor.</li></ol>

<div class="references_section">