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.

artwork21
35.2k8 gold badges69 silver badges135 bronze badges
asked May 9, 2012 at 4:24

1 Answer 1

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()
answered May 9, 2012 at 11:41
2
  • Thank you! That worked great. Do you know how I can change this to also make it save edits? Commented May 9, 2012 at 13:33
  • @Xoph, Please open a mew question regarding saving edits. Commented May 9, 2012 at 14:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.