When you’re working on large projects, it’s common to have a bunch of open windows cluttering your desktop. Closing all the windows you’re not working on is tedious. To automate this task, create a new macro and paste in this code:
Sub Closeallexceptcurrent() Dim i As Integer Dim sCurrWin As String = DTE.ActiveDocument.Name With DTE For i = .Documents.Count To 1 Step -1 If .Documents.Item(i).Name <> sCurrWin Then If Not .Documents.Item(i).Saved Then .Documents.Item(i).Close(vsSaveChanges.vsSaveChangesYes) Else .Documents.Item(i).Close(vsSaveChanges.vsSaveChangesNo) End If End If Next End With End Sub