|
|
|
|
|
|
Word
|
Close all open Word documents and quit Word
|
|
Ease of Use
|
Easy
|
Version tested with
|
2000, 2003
|
Submitted by:
|
MOS MASTER
|
Description:
|
Programmatically close all open Word documents and quit Word.
|
Discussion:
|
You want an easy way to close all open documents and want to quit Word at the same time. The sub below provides that. If you need to save every doc then change [b]SaveChanges to wdSaveChanges[/b]
Important: this sub has to run global in Normal.dot or an addin to perform correctly and quit Word after execution.
|
Code:
|
instructions for use
|
Sub CloseAll()
With Application
.ScreenUpdating = False
Do Until .Documents.Count = 0
.Documents(1).Close SaveChanges:=wdDoNotSaveChanges
Loop
.Quit SaveChanges:=wdDoNotSaveChanges
End With
End Sub
|
How to use:
|
- Open your Word document.
- Press Alt + F11 to open VBE.
- Press CTRL+R to view Project Explorer
- Select Normal Project (Mother of all Word documents)
- Choose: Insert-Module. (Insert -> module)
- Paste the code there in the window at right. (F7)
- Close VBE (Alt + Q or press the X in the top right hand corner).
- Save the file.
|
Test the code:
|
- From Word, press Alt + F8 to open the macro dialog box.
- Select CloseAll
- Click Run.
|
Sample File:
|
Close all open Word documents and quit Word.zip 5.37KB
|
Approved by mdmackillop
|
This entry has been viewed 137 times.
|
|