<?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 how to close &amp;quot;Current&amp;quot; Map Document? in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512636#M5477</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can I close a map document via python?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to run a script which references the map document&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do_some_stuff()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.saveACopy(r"C:\xx\yy\zz.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.startfile(r"C:\xx\yy\zz.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and now i would like to close the "old" mxd???&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only thing I found to work is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os._exit()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but this kind of kills ArcMap too brutal... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. ArcSOCP.exe and ArcSOMP.exe won't close (for the next 10 min..)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is there anything like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.close()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ????&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or a better closing method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sure, it is just one click to exit Arcmap. It is not extremely important, but nevertheless I would like to enforce closing the mapDocument in my script (in a proper way)...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Dec 2010 15:44:52 GMT</pubDate>
    <dc:creator>CosminTana</dc:creator>
    <dc:date>2010-12-02T15:44:52Z</dc:date>
    <item>
      <title>how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512636#M5477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How can I close a map document via python?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to run a script which references the map document&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("Current")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;do_some_stuff()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;....&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.saveACopy(r"C:\xx\yy\zz.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.startfile(r"C:\xx\yy\zz.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and now i would like to close the "old" mxd???&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The only thing I found to work is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os._exit()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but this kind of kills ArcMap too brutal... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. ArcSOCP.exe and ArcSOMP.exe won't close (for the next 10 min..)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is there anything like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.close()&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ????&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or a better closing method?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sure, it is just one click to exit Arcmap. It is not extremely important, but nevertheless I would like to enforce closing the mapDocument in my script (in a proper way)...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Dec 2010 15:44:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512636#M5477</guid>
      <dc:creator>CosminTana</dc:creator>
      <dc:date>2010-12-02T15:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512637#M5478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Cosmin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm assuming that you are running your script though the ArcPy window, am I correct? If so, why not using IDLE or PythonWin instead?&amp;nbsp; That way you would not need to open up an ArcMap session to do what you need to do, you would just refer to your map document object instead:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(&amp;lt;mxd path&amp;gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your issue description does not tell me why you need to "close" ArcMap.&amp;nbsp; If you could elaborate then I might be able to help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Dec 2010 15:57:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512637#M5478</guid>
      <dc:creator>EricAubert</dc:creator>
      <dc:date>2010-12-06T15:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512638#M5479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Application.shutdown&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Dec 2010 11:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512638#M5479</guid>
      <dc:creator>Venkata_RaoTammineni</dc:creator>
      <dc:date>2010-12-07T11:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512639#M5480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wrote my script in pythonwin and appended it to a toolbox...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For the future I want to make my script flexible. That means,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to be able to call it from ArcCatalog (the preferred method) but also from ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I call it from ArcMap, I want to close exactly that ArcMap session which called the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There is a reason for this, but back to the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far os._exit() is the only thing which works, but not optimal...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.system('taskkill /IM Arcmap*')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;would close the ArcMap session the correct way- but unfortunately it will close all open ArcMap sessions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Application.shutdown &amp;lt;-- Couldn't find anything on this in combination with Python...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Can your write the correct syntax maybe?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Dec 2010 21:29:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512639#M5480</guid>
      <dc:creator>CosminTana</dc:creator>
      <dc:date>2010-12-08T21:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512640#M5481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Application.shutdown is vba code syntax...I dont know Python....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks and Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Venkat&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2010 09:36:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512640#M5481</guid>
      <dc:creator>Venkata_RaoTammineni</dc:creator>
      <dc:date>2010-12-10T09:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: how to close "Current" Map Document?</title>
      <link>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512641#M5482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Cosmin,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The os.system('taskkill /IM Arcmap*') was what I needed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2013 13:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/how-to-close-quot-current-quot-map-document/m-p/512641#M5482</guid>
      <dc:creator>EricMahaffey</dc:creator>
      <dc:date>2013-08-29T13:47:02Z</dc:date>
    </item>
  </channel>
</rss>

