Skip to content

Instantly share code, notes, and snippets.

@AlexArcPy
Created November 5, 2017 09:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexArcPy/bbba9a77866e34b9e3d55de39812b43c to your computer and use it in GitHub Desktop.
Save AlexArcPy/bbba9a77866e34b9e3d55de39812b43c to your computer and use it in GitHub Desktop.
Create a new empty ArcGIS map document (.mxd) with Python (comtypes)
from comtypes.client import GetModule, CreateObject
from snippets102 import GetStandaloneModules, InitStandalone
esriCarto = GetModule(r"C:\Program Files (x86)\ArcGIS\Desktop10.5\com\esriCarto.olb")
# First time through, need to import the “StandaloneModules”. Can comment out later.
GetStandaloneModules()
InitStandalone()
# Create a map document object
mxdObject = CreateObject(esriCarto.MapDocument, interface=esriCarto.IMapDocument)
# Create new mxd file
mxdObject.New(r'C:\Temp\MapTemplate.mxd')
mxdObject.Save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment