How to mark a map document as changed or unchanged


Sometimes you want to mark a map document as changed so that you will be prompted to save the document when exiting ArcMap. Sometimes you do not want to be prompted to save. This tip shows how to do it.

How to use

  1. Copy the subroutines to the VBA editor of an opened map document.
  2. Execute a subroutine.
  3. Exit the map document and you will be prompted to save the document if you execute the MarkDocChanged subroutine. If you execute MarkDocUnchanged, you will not be prompted to save.
[VBA]
Public Sub MarkDocChanged()
    Dim pDocDirty As IDocumentDirty2
    Set pDocDirty = ThisDocument
    pDocDirty.SetDirty
End Sub

Public Sub MarkDocUnchanged()
    Dim pDocDirty As IDocumentDirty2
    Set pDocDirty = ThisDocument
    pDocDirty.SetClean
End Sub