Monday, March 21, 2005

Close All for VS 2003

Imports EnvDTE
Imports System.Diagnostics

Public Module CloseAll
Private maxTries As Integer = 3
Sub CloseAll()
Dim currentTries As Integer = 0
While (Not exeClose()) And currentTries < maxTries
currentTries += 1
End While
End Sub

Function exeClose() As Boolean
Try
For Each d As Document In DTE.Documents()
d.Close(vsSaveChanges.vsSaveChangesPrompt)
Next
Catch
Return False
End Try

Return True
End Function

End Module

No comments: