AnsweredAssumed Answered

Arcobjects in Python script tool to suppress the Save dialog

Question asked by mudo on Jan 14, 2015



I am working on a Python script tool that uses wrapped Arcobjects classes and interfaces to give me more control of the ArcMap application.  I used variants of the helper functions found here: Python, comtypes and ArcObjects: Error creating AppROT object - Geographic Information Systems Stack Exchange  , to do the wrapping.


I would like the tool to open an .mxd in the existing application (which it does), but I want to suppress the 'Save' dialog when the current mxd closes.  My question is: when I run the following code from the interactive window, I get the behavior that I want,  the mxd (user_doc) is opened in the current ArcMap session, and the 'Save' prompt does not appear.  When the code executes in the script tool, or in my addin, the 'Save' dialog always opens.  Is it possible to suppress the Save dialog using python and ArcObjects?


Thanks for any clues you can provide

I am running ArcGIS 10.2.2 on Windows Server 2008 R2.


# Get a pointer to current app
    this_app = comtypes.client.CreateObject(esriFramework.AppRef,
    # Get a pointer to the current Document
    this_doc = this_app.Document.QueryInterface(esriFramework.IDocumentDirty2)