
370Microsoft Visual Studio 2010: A Beginner’s Guide
'Logic to add product Return newProdID
End Function
End Class
To fix the problem with the macro (for the C# code) opening the Customer.cs file, notice that the macro has three statements that activate the Customer.cs file. Comment out each of these statements as shown in the following excerpt:
…
'DTE.Windows.Item("Customer.cs").Activate()
…
'DTE.Windows.Item("Customer.cs").Activate() DTE.Find.FindWhat = "{"
…
'DTE.Windows.Item("Customer.cs").Activate()
…
If you were to write your own macro via code, a quick way to figure out what code you have to write is to start the macro recorder in VS
Summary
Now you know about various techniques for customizing VS. You learned how to customize projects and save your work as a custom project template. In a related task, you saw how you can create a new file and then save that file as a custom item template. This gives you the ability to use projects and project items in a way that you want. In addition to using snippets that ship with VS, you learned how to find the definition of existing snippets and either modify a snippet or create a brand new snippet from scratch. You also saw how to organize snippets with the Snippets Manager. Finally, you learned how to record and save repeatable actions with VS macros. You can also use the Macro editor to customize existing macros or create new ones on your own.
Macros are very powerful, but VS has even more capabilities for allowing you to extend the IDE. You’ll learn how to extend VS by writing