Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Word 2007 Macro Help Please!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MrBill - 05 Jul 2007 22:57 GMT
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
====================
old man - 06 Jul 2007 04:40 GMT
Hi,

Try this (on one line)

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

old man

> 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
[quoted text clipped - 20 lines]
> End Sub
> ====================
MrBill - 06 Jul 2007 14:04 GMT
That worked, thanks Old Man!  BTW - how old are you?  :)

- MrBill

>Hi,
>
[quoted text clipped - 29 lines]
>> End Sub
>> ====================
old man - 06 Jul 2007 22:56 GMT
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

> 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
[quoted text clipped - 20 lines]
> End Sub
> ====================
Russ - 07 Jul 2007 01:22 GMT
Message in line below.
> Hi,
>
[quoted text clipped - 3 lines]
> 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.

> old man
>
[quoted text clipped - 22 lines]
>> End Sub
>> ====================

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

MrBill - 07 Jul 2007 04:02 GMT
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

>Hi,
>
[quoted text clipped - 30 lines]
>> End Sub
>> ====================
billmccoy - 10 Jul 2007 23:08 GMT
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

> 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
[quoted text clipped - 20 lines]
> End Sub
> ====================
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.