vs-macros

How can I turn DTE.ActiveWindow.Selection into the closest CodeElement in a VS2008 Macro?

I'm working with the Visual Studio 2008 object model as seen here: VS2008 Automation Object Model Chart. I want to act on a CodeElement in a VS2008 Marco, one that is chosen by the user's text selection in the current .cs document. While I don't really care how I get it, this is what I tried: The VS object model gives you DTE.ActiveWin...

Clean up unwanted code C#

I got a C# application with Visual Studio 2005. The code has some 300KLOC code, which has been raped over 3 years. When I was going through code found out that lot of unused functions/methods/properties. Its not possible to clean the code manually (Requires checking each member and if found no references delete it.) I am looking to au...

Visual Studio 2008 macro question

I have been trying to write a short macro in Visual Studio that activates the FindSymbolResults (Constants.vsWindowKindFindSymbolResults), and then moves to the next item in the list (if anyway) and calls Edit.GotoReference on it. The first and last parts - show the window and call Edit.GoToReference - are done, but I am struggling with...

How can I make a Visual Studio Macro to attach the debugger to all instances of w3wp.exe?

I'm normally developing web apps, and a surprisingly large amount of my work time is spent doing "Ctrl + Alt + P", sorting by Process Name, and picking w3wp.exe to attach my debugger. To make matters worse, I'm working on an app that spans several application pools, so I normally have 2 or 3 instances of w3wp.exe, and it's impossible to...

Collapse all Visual Studio toolbox regions shortcut

Is there a keyboard shortcut or macro to collapse all regions in Visual Studio's toolbox? (Failing either of those, I'll take an addin that allows this!) ...

Toggle "Break when an exception is thrown." using macro or keyboard shortcut.

Note: The accepted solution doesn't quite work, but it's very close. Is there a macro or keyboard shortcut that will toggle "break when an exception is thrown" without using the GUI. Opening the dialog with ctrl+alt+e and checking the "Common Language Runtime Exceptions" "Thrown" box then clicking OK is simple enough, but this is som...

Visual Studio 2005 macros won't run

I'm trying to run the Visual Studio 2005 sample macro that attaches the debugger to calc.exe. Neither it nor any other macro seem to do anything when I run them. Calc.exe is running. "Tools->Options->Add-in/Macros Security->Allow macros to run" is checked. The error list shows no errors. ...

Visual Studio macros: WindowActivated handler turns clicks into double clicks

If I add a WindowEvents_WindowActivated handler to my Visual Studio 2005 Macros EnvironmentEvents module, I get a weird side-effect: when I click from one window to another in Visual Studio, that click is treated as a double click. So for instance, I put the focus in an editor window and click a file in Solution Explorer, and the file o...

Where is a good Visual Studio Macro to iterate and list all menus (VS2008 if pos.)?

I've been explained there is a Macro which iterates through all the menus. Having checked CodeProject, and various places on the web I'm out of luck so far. Does anyone know any better? Thanks Beth ...

Making a macro to generate a custom show in Powerpoint

I want to make a macro for PowerPoint, to generate a custom show, containing all the slides from my PowerPoint but in random order. How would I do this? I want to be able to run it and create different custom shows each time. It's been 3 years since I used PowerPoint, and the only experience I have with VB was a little bit of VB6 in 200...

Find missing references in Visual Studio

I have a huge solution file with lots of projects in it. I suspect that some of the projects that are referenced to by other projects are missing from solution. Is there an easy way to detect missing references in Visual Studio? (I am using 2008) ...

Visual Studio macro: Find files that aren't included in the project?

I'd like to write a macro to crawl through the files in my project directory and find files that aren't included in the project. In playing around with the DTE object, I see that the Project object has ProjectItems; if a ProjectItem represents a directory, then it has its own ProjectItems collection. This gives me all files that are in...

VS macros: How to change command line arguments for debug in C# project properties?

Is it possible using macros in Visual studio 2008 to change command line arguments for debug project? In project->properties->debug i can set manually comm line args for debugging. I'd like to change them with macros, not with hands. ...

OnBuildBegin does not fire in Visual Studio Macro until I run it from Macro Explorer

I have the following Visual Studio Macro: Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports MyMacros.EnvironmentEvents Imports System.Diagnostics Public Module Module1 Private WithEvents buildEvents As EnvDTE.BuildEvents = EnvironmentEvents.BuildEvents Public Sub BuildEvents_OnBuildBegin() Handles buildE...

Setting a VCProject property to default

I'm trying some VS2005 IDE macros to modify a large amount of projects (~80) within a solution. Some of the properties I wish to set do expose a programmatic interface to 'default', but many others do not. Is there a generic way to set such properties to their default? (eventually meaning erasing them from the .vcproj file) Simplified ...

Visual Studio Macros: Loop through Selection, add .Append(" and ") to each line in selection

Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = ".Append(""" + DTE.ActiveDocument.Selection.Text + """)" End Sub But I can't seem to figure out how to loop through each line of text in the selection. Any thoughts? ...

Can I have a macro run whenever I save a file in Visual Studio 2005?

When I save a file in Visual Studio 2005, I'd like to have a macro also run that updates a copyright (through a regular expression search and replace). I'm not new to regular expressions, but I am new to VB/VBA and Visual Studio macros, so what I need help with specifically is: getting a macro to run upon save, preferably after I pres...

Can I have a macro in Visual Studio 2005 call a DOS command and redirect the output to a file?

I'd like to have a macro in Visual Studio 2005 that calls a DOS command and redirects the output (stdout and stderr) to a file. Just calling the command and ">" redirecting it will not capture stderr, so there are two parts to this: calling a DOS command capturing both stderr and stdout to a file during that call I'd then like to o...

how can I import custom dll onto my visual studio macro project?

no way? standard .net dll only? ...

should I include VB macros in source control with my project?

For a C# project, I make use of several Visual Basic macros in Visual Studio. I was just considering that these would be of use to other developers that work on the C# project. The macros so far include removing trailing whitespace on save, organizing using directives and removing unnecessary ones, and an override for Ctrl-M Ctrl-O tha...