Word 2007 Macro Help Please!

M

MrBill

I need a macro to close as many documents as might be open in Word
2007, saving none of the changes, then closing Word. The following
(borrowed from Excel 2003 and modified) works with 1 document but not
when I have 2 or more. Can anyone help?

Thanks, Bill

====================
Sub CloseAll_Quit()
'
' CloseAll_Quit Macro
' Written by Bill Mullin
'

On Error GoTo errorHandler
ActiveDocument.Close _
SaveChanges:=wdDoNotSaveChanges, _
OriginalFormat:=wdWordDocument
errorHandler:
If Err = 4198 Then MsgBox "Document was not closed"

Application.Quit
End Sub
====================
 
O

old man

Hi,

Try this (on one line)

Documents.Close
saveChanges:=wdDoNotSaveChanges,OriginalFormat:=wdWordDocument


old man
 
O

old man

Hi,

I am old enough to have bought an original PC (I was already working in IT)
when it was first released.

By the way it is nice to check off a reply as answered if you are satisfied
with the reply.

old man
 
R

Russ

Message in line below.
Hi,

I am old enough to have bought an original PC (I was already working in IT)
when it was first released.

By the way it is nice to check off a reply as answered if you are satisfied
with the reply.
Hey old man,
I'm handling these newsgroups' messages through an email client, so I don't
see so-called ratings boxes or other checkboxes on a website. All I can do
is say "Thanks" as my feedback to other people helping me, which I try to
do. So don't feel bad, if 'my' feedback boxes are unused.
 
M

MrBill

That's not old, I'm old enough to have debugged wired boards on
accounting machines before my shop got a 1401 PC which we programmed
in Autocoder! :) That 1401 was something . . . 16 KB of core, 6
humongous tape drives, lights flashing like crazy, cost $3M, filled a
room, had about 1/1000th the processing power of my current PC. Those
were the good old days . . . NOT!

- MrBill
 
B

billmccoy

I think this would do the trick:

Public Sub CloseAllWindowsAndQuit()
While Application.Windows.Count > 0
With Windows(1)
.Activate
.Close savechanges:=wdDoNotSaveChanges
End With
Wend
Application.Quit
End Sub

That's all!

With kind regards,

W. Kooy
Netherlands
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top