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 Answer 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– Xoph2012年05月09日 13:33:23 +00:00Commented May 9, 2012 at 13:33
-
@Xoph, Please open a mew question regarding saving edits.artwork21– artwork212012年05月09日 14:02:04 +00:00Commented May 9, 2012 at 14:02