How Can I Close an mxd using arcpy script

7373
6
08-25-2012 09:15 PM
OLANIYANOLAKUNLE
Occasional Contributor II
How Can I Close an mxd using arcpy script. Thanks
Tags (2)
6 Replies
RichardFairhurst
MVP Honored Contributor
How Can I Close an mxd using arcpy script. Thanks


Python is still more of a geoprocessing oriented language is GIS than a full blown windows application management language.  The arcpy options only let you save or saveacopy of the document, but there is no close option.  I haven't seen any native Python that manages open Wndows applications.  Perhaps there is an extension someone has written that I am unaware of, but the python.org help does not come up with anything I can find.

I think you are expecting more out of Python than ESRI has tried to support at this time.
0 Kudos
BruceBacia
Occasional Contributor
This will kill ArcMap itself.

import os
os.system("TASKKILL /F /IM ArcMap.exe") 
0 Kudos
BruceBacia
Occasional Contributor
Also you can open a specific mxd like this:

import os
os.startfile("Your MXD Path") 
0 Kudos
RichardFairhurst
MVP Honored Contributor
This will kill ArcMap itself.

import os
os.system("TASKKILL /F /IM ArcMap.exe") 


I stand corrected.
0 Kudos
OLANIYANOLAKUNLE
Occasional Contributor II
Thanks! I got it
0 Kudos
EdMorris
Esri Contributor

Hi

I have just blogged on this >>

Using Python to close an ArcMap map document down | Spatial Needs....

This will show you how to close an MXD down by name....

thanks ed