Untitled

Random thoughts about everything and nothing

Good ‘ol macros

leave a comment »

Been going through my existing VS.NET 2003 macros the other day…

Close all active documents:

Sub CloseAllDocuments()
Try
If DTE.ActiveDocument.Collection.Count > 0 Then
DTE.ActiveDocument.Collection.CloseAll()
End If
Catch
‘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.”)
Return
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
Next

UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
End Sub

Advertisements

Written by Michael

March 5, 2006 at 8:31 pm

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: