View Full Version : Close all documents apart from the active one
neodjandre
07-14-2008, 02:15 AM
Hello,
I am looking for some vba code to close all word documents apart from the active document.
could someone help please ?
thanking you in advance
andy
lucas
07-14-2008, 10:32 AM
This seems to work:
Option Explicit
Sub CloseAllExceptActive_NoSave()
With Application
.ScreenUpdating = False
'Loop Through open documents
Do Until .Documents.Count = 1
'Close no save
.Documents(1).Close SaveChanges:=wdDoNotSaveChanges
Loop
.ScreenUpdating = True
End With
End Sub
It is set up to not save changes to the open documents. If you want to close them and save changes then change this line in the code.
.Documents(1).Close SaveChanges:=wdSaveChanges
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.