Re: getting word to prompt to save on Close

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Hal

I think the problem here is that the Word document isn't "dirty": there are
no changes to be saved, so the user isn't prompted to save any.

For testing, use oWordDoc.Saved = False before the oWordDoc.Close line. This
"dirties" the document. Word then thinks there are changes to be made, and
the prompt to save works as intended.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word


"Hal Tz" <HalTz@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F9C7741C-6232-497C-968F-607A30316DCD@xxxxxxxxxxxxxxxx
> Look like I have the opposite problem of a lot of threads here. I'm a
> total
> newbie to Word Automation, am doing Document.Close, and have tried
> oWordDoc.Close SaveChanges:=wdPromptToSaveChanges,
> OriginalFormat:=wdPromptUser
> and many variation on it, it always closes the doc saving any changes
> without ptompting. Here's the code snippet. Any ideas? Thanks.
>
> Dim oWD As Word.Application
> Dim oWordDoc As Word.Document
> Set oWD = New Word.Application
> Set oWordDoc = oWD.Documents.Open("c:\z.doc")
> oWD.Visible = True
> oWD.Activate
> MsgBox ("hit OK to close")
> oWordDoc.Close SaveChanges:=wdPromptToSaveChanges ,
> OriginalFormat:=wdPromptUser
> --
> Hal


.



Relevant Pages

  • Re: Converting Word 6.0 to Word 2002?
    ... Save it as "Word Document." ... does the prompt ask if you want to convert ... Microsoft MVP (Word) ... "Bob Henry" wrote: ...
    (microsoft.public.word.docmanagement)
  • Re: Compare documents with AppleScript
    ... set doc1 to choose file with prompt "Please select a Word document file:" ... set doc2 to choose file with prompt "Please select a Word document file:" ...
    (microsoft.public.mac.office.word)
  • Finding and Inserting
    ... in the word document that are in [brackets]. ... I want a prompt to come up as ask "insert title". ... acceptance of our offer of employment as an Accountant. ...
    (microsoft.public.word.vba.beginners)
  • Numbering in footer - prompts to save the document after printing
    ... I have a word document with footer, ... number as X of Y. I added the page number from 'Header ... and Footer Tool' using the options, ... We dont want the word to prompt. ...
    (microsoft.public.word.numbering)
  • Re: Recursively find delimited word in document
    ... for the replacement text as each string is found. ... .Collapse Direction:=wdCollapseStart ... I am developing a VB6 app that opens a Word document to ... it with a string which I prompt the user for. ...
    (microsoft.public.vb.general.discussion)