devxlogo

Close and Save All Except Your Current Window

Close and Save All Except Your Current Window

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
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist