Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

How To Stop Ms Word From Prompting To Save At Close?


  • Please log in to reply
1 reply to this topic

#1 Tool1248

Tool1248

  • Members
  • 4 posts
  • OFFLINE
  •  
  • Local time:01:33 PM

Posted 27 June 2007 - 07:49 PM

I have a script that opens and prints Word files, then closes. Every so often, upon closing, Word prompts to save because the file has changed and it throws my script off. Is there a way, via registry hack, etc..., to disable the "Do you want to save your changes to..." prompt?

Thanks,
Tool1248

BC AdBot (Login to Remove)

 


#2 tos226

tos226

    BleepIN--BleepOUT


  • Members
  • 1,588 posts
  • OFFLINE
  •  
  • Gender:Female
  • Location:LocalHost
  • Local time:12:33 PM

Posted 27 June 2007 - 09:49 PM

Word, and all Office apps for that matter, prompt when it thinks something changed.
Some of the reasons why Word thinks so are change of dates, pages, table of contents, printer.
Likely you've saved the document, but then went to some other printer - bingo, a change.

Look into VBA commands. The full syntax for close includes the flag to be quiet. Tie a macro to the document and you should be good to go.

From Help:

This example prompts the user to save the active document before closing it. If the user clicks Cancel, error 4198 (command failed) is trapped and a message is displayed.

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


Probably if you say saveChanges:=False it'll work. Or the OriginalFormat value might need change. I don't know.

Ok, I looked some more, here's the complete syntax description

Close method as it applies to the Document and Documents objects.

Closes the specified document or documents.

expression.Close(SaveChanges, OriginalFormat, RouteDocument)
expression Required. An expression that returns one of the above objects.

SaveChanges Optional Variant. Specifies the save action for the document. Can be one of the following WdSaveOptions constants: wdDoNotSaveChanges, wdPromptToSaveChanges, or wdSaveChanges.

OriginalFormat Optional Variant. Specifies the save format for the document. Can be one of the following WdOriginalFormat constants: wdOriginalDocumentFormat, wdPromptUser, or wdWordDocument.

RouteDocument Optional Variant. True to route the document to the next recipient. If the document doesn't have a routing slip attached, this argument is ignored.


Edited by tos226, 27 June 2007 - 09:59 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users