Solved! Go to Solution.
old thread but i thought i would post my answer as it does not require an existing map doc
this does assume that you have arcMap installed and not just arcpy. but who is using arcpy w/o having ArcMap installed?
{
map_file = r'c:\test\test_map..mxd'
# open and close a file
open(map_file,'r').close()
# open the file with default application
os.startfile(map_file)
# sleep for a couple minutes to allow the file to be fully opened
time.sleep(120)
# kill the application in a pretty violent way yet not corrupting the file.
os.system("taskkill /im arcmap.exe /f")
# work with yout map
mxd = arcpy.mapping.MapDocument(map_file)
}
Old thread, but I just used your code although I had to change 'r' to 'w+' in third line. Is this due to changes in python since 2014? I don't understand how your code could work because with the open function in 'read' mode it could not create the file.