Tuesday, June 7, 2011

CloseAllTakeNoPrisoners

Although as a rule I "Never Close, Never Minimize", I confess to times when I have literally dozens of documents left open after a failed attempt to batch-process a folder.
At that time I like to fix the problem and start with a clean slate.
The little macro below shrugs and wipes my slate clean!

Public Sub CloseAllTakeNoPrisoners()
''' Close all open documents without saving a single one; discard all recent changes.
Dim doc As Document
For Each doc In Application.Documents
doc.Close savechanges:=wdDoNotSaveChanges
Next doc
If Documents.Count > 0 Then
Documents.Close savechanges:=wdDoNotSaveChanges
Else
End If
End Sub

No comments:

Post a Comment