Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to save the map document that is currently open. How do I write the code? I have tried many suggestions that I found using Google searches, but nothing works. Currently I have:

Dim clickedDoc As IMapDocument = My.ArcMap.Application.Document
clickedDoc.Save(True, False)

which causes ArcMap to crash. I did get it to work with some other code, but it wouldn't actually save.

Also, this should be a background job. So no save dialog should come up.

share|improve this question
up vote 1 down vote accepted

You can just use the built in ArcMap Command Save, see example below.

    Dim pUID As New UID
    Dim pCmdItem As ICommandItem
    ' Use the GUID of the Save command
    pUID.Value = "{119591DB-0255-11D2-8D20-080009EE4E51}"
    ' or you can use the ProgID
    ' pUID.Value = "esriArcMapUI.MxFileMenuItem"
    pUID.SubType = 3
    pCmdItem = My.ArcMap.Application.Document.CommandBars.Find(pUID)
share|improve this answer
Thank you! That worked great. Do you know how I can change this to also make it save edits? – Xoph May 9 '12 at 13:33
@Xoph, Please open a mew question regarding saving edits. – artwork21 May 9 '12 at 14:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.