Random thoughts about everything and nothing

Macros – Visual Studio 2003

leave a comment »

Been going through my existing VS.NET 2003 macros the other day… Close all active documents:

Sub CloseAllDocuments()
If DTE.ActiveDocument.Collection.Count > 0 Then
End If
‘Lazy catch, we do nothing
End Try
End Sub

Or just use “>Edit.CloseAll” in the immediate window.

To collapse all projects in the solution explorer:

Sub CollapseAll()
Dim UIHSolutionExplorer As UIHierarchy
UIHSolutionExplorer = DTE.Windows.Item( _
Constants.vsext_wk_SProjectWindow).Object() If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
MsgBox(“Nothing to collapse. You must have an open solution.”)
End If

Dim UIHSolutionRootNode As UIHierarchyItem
UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)

Dim UIHItem As UIHierarchyItem
For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
UIHItem.UIHierarchyItems.Expanded = False

End Sub


Written by Michael

March 19, 2006 at 12:21 am

Posted in VSX

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: