| < Free Open Study > |
|
Sometimes it would be nice just to clear the desktop by closing all windows but the active window. The following procedure will do that for you. It uses the Documents collection and compares the names of the documents to the name of the current document before determining whether or not to close the window.
Public Sub CloseAllButCurrentWindow() Dim i As Integer Dim sCurrWin As String = oVB.ActiveDocument.Name Debug.WriteLine(sCurrWin) With oVB On Error Resume Next 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
| < Free Open Study > |
|