<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Arcobjects in Python script tool to suppress the Save dialog in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcobjects-in-python-script-tool-to-suppress-the/m-p/750913#M57997</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on a Python script tool that uses wrapped Arcobjects classes and interfaces to give me more control of the ArcMap application.&amp;nbsp; I used variants of the helper functions found here: &lt;A href="http://gis.stackexchange.com/questions/5017/python-comtypes-and-arcobjects-error-creating-approt-object/5018#5018" title="http://gis.stackexchange.com/questions/5017/python-comtypes-and-arcobjects-error-creating-approt-object/5018#5018" rel="nofollow noopener noreferrer" target="_blank"&gt;Python, comtypes and ArcObjects: Error creating AppROT object - Geographic Information Systems Stack Exchange&lt;/A&gt;&amp;nbsp; , to do the wrapping. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; My question is: when I run the following code from the interactive window, I get the behavior that I want,&amp;nbsp; the mxd (user_doc) is opened in the current ArcMap session, and the 'Save' prompt does not appear.&amp;nbsp; When the code executes in the script tool, or in my addin, the 'Save' dialog always opens.&amp;nbsp; Is it possible to suppress the Save dialog using python and ArcObjects?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any clues you can provide&lt;/P&gt;&lt;P&gt;I am running ArcGIS 10.2.2 on Windows Server 2008 R2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Get a pointer to current app
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_app = comtypes.client.CreateObject(esriFramework.AppRef,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interface=esriFramework.IApplication)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a pointer to the current Document
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_doc = this_app.Document.QueryInterface(esriFramework.IDocumentDirty2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_doc.setClean()
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_app.OpenDocument(user_doc)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 07:53:20 GMT</pubDate>
    <dc:creator>MarshallUdo</dc:creator>
    <dc:date>2021-12-12T07:53:20Z</dc:date>
    <item>
      <title>Arcobjects in Python script tool to suppress the Save dialog</title>
      <link>https://community.esri.com/t5/python-questions/arcobjects-in-python-script-tool-to-suppress-the/m-p/750913#M57997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working on a Python script tool that uses wrapped Arcobjects classes and interfaces to give me more control of the ArcMap application.&amp;nbsp; I used variants of the helper functions found here: &lt;A href="http://gis.stackexchange.com/questions/5017/python-comtypes-and-arcobjects-error-creating-approt-object/5018#5018" title="http://gis.stackexchange.com/questions/5017/python-comtypes-and-arcobjects-error-creating-approt-object/5018#5018" rel="nofollow noopener noreferrer" target="_blank"&gt;Python, comtypes and ArcObjects: Error creating AppROT object - Geographic Information Systems Stack Exchange&lt;/A&gt;&amp;nbsp; , to do the wrapping. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp; My question is: when I run the following code from the interactive window, I get the behavior that I want,&amp;nbsp; the mxd (user_doc) is opened in the current ArcMap session, and the 'Save' prompt does not appear.&amp;nbsp; When the code executes in the script tool, or in my addin, the 'Save' dialog always opens.&amp;nbsp; Is it possible to suppress the Save dialog using python and ArcObjects?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any clues you can provide&lt;/P&gt;&lt;P&gt;I am running ArcGIS 10.2.2 on Windows Server 2008 R2. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Get a pointer to current app
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_app = comtypes.client.CreateObject(esriFramework.AppRef,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interface=esriFramework.IApplication)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get a pointer to the current Document
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_doc = this_app.Document.QueryInterface(esriFramework.IDocumentDirty2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_doc.setClean()
&amp;nbsp;&amp;nbsp;&amp;nbsp; this_app.OpenDocument(user_doc)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcobjects-in-python-script-tool-to-suppress-the/m-p/750913#M57997</guid>
      <dc:creator>MarshallUdo</dc:creator>
      <dc:date>2021-12-12T07:53:20Z</dc:date>
    </item>
  </channel>
</rss>

