none
Document.Saved property not set correctly? RRS feed

  • Question

  • I am running code on opening of a document to check footer info, and prompt user to update if "incorrect".  The last two lines of the Sub are:

        ActiveDocument.Saved = False
        jjj = MsgBox(ActiveDocument.Name, , ActiveDocument.Saved)
       
    End If

    End Sub

    The MsgBox shows the name of the doc I opened (Jambalaya.doc) and shows FALSE, as I would expect.

    But after clicking OK on the MsgBox, if I go to my Immediate window and type in ?ActiveDocument.Saved, it returns TRUE.

    And, when I close the doc, it does not prompt to be saved.  Is there some other way I should be setting the doc to 'dirty'?

    Thank you,

    KePaHa

    Friday, May 9, 2014 4:46 PM

Answers

  • Hi KepaHa

    <<But after clicking OK on the MsgBox, if I go to my Immediate window and type in ?ActiveDocument.Saved, it returns TRUE.

    And, when I close the doc, it does not prompt to be saved.  Is there some other way I should be setting the doc to 'dirty'?>>

    Possibly, there's another add-in running that's changing the setting... There are a number of add-ins that will do this (especially VSTO add-ins) as part of their Startup actions in order to prevent the Save prompt from appearing if the document has not yet been edited.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, May 11, 2014 3:46 PM
    Moderator

All replies

  • I am unable to reproduce that behaviour. If I set the saved bit 'dirty' via 'ActiveDocument.Saved = False', the message box returns False, as does '?ActiveDocument.Saved' in the Immediate window, even for a document that hasn't been edited.

    In any event, if you edit the document, Word will set the 'dirty' flag automatically; there is no need for you to set it programmatically.

    If you're not getting the expected behaviour, try repairing the Office installation (via Programs & Features > Microsoft Office > Change in the Windows Control Panel).


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, May 9, 2014 10:50 PM
  • Hi KepaHa

    <<But after clicking OK on the MsgBox, if I go to my Immediate window and type in ?ActiveDocument.Saved, it returns TRUE.

    And, when I close the doc, it does not prompt to be saved.  Is there some other way I should be setting the doc to 'dirty'?>>

    Possibly, there's another add-in running that's changing the setting... There are a number of add-ins that will do this (especially VSTO add-ins) as part of their Startup actions in order to prevent the Save prompt from appearing if the document has not yet been edited.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, May 11, 2014 3:46 PM
    Moderator
  • Yes.  Thank you.  It is another add-in that is causing this.  I am working with the vendor now to see how to prevent this add-in from marking documents as SAVED when they are not.
    Tuesday, May 20, 2014 7:25 PM