2

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.

1

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)
    pCmdItem.Execute()
  • 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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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