I am looking for a way to check the mxd version of a bunch of mxds. I found a script here at ArcPy method to determine ArcMap document version

I am using ArcGIS 10.3.1 on my desktop.

It goes through the directories and for every mxd it finds it grabs a bunch of details, one of which is the version. My only problem is that sometimes it can not find the version of ArcGIS; it seems to be about 50/50. At first I thought if it didn't return that correct value that meant it was below 10.0. But running my script on 200 mxds it returned the value 9.3 a few times, which means that the ones where it does not return any value could be any version and not just something below 10.0.

The current code taken from the other question:

def getMXDVersion(mxdFile):
    matchPattern = re.compile("9.2|9.3|10.0|10.1|10.2|10.3")
    with open(mxdFile, 'rb') as mxd:
        fileContents = mxd.read().decode('latin1')[1000:4500]
        removedChars = [x for x in fileContents if x not in [u'\xff',u'\x00',u'\x01',u'\t']]
        joinedChars = ''.join(removedChars)
        regexMatch = re.findall(matchPattern, joinedChars)
        #print mxdFile
        #print joinedChars
        #print regexMatch
        if len(regexMatch) > 1:
            version = regexMatch[len(regexMatch) - 1]
            return version
        elif len(regexMatch) == 1:
            version = regexMatch[0]
            return version
            return 'version could not be determined for ' + mxdFile

Is there any other way to find the map document's version number?

  • I mention that thread in my initial question. I got the code from there. If i asked the person for help on that thread I assumed someone would have told me to make a new question and ask.
    – Sharm
    Commented Jun 10, 2015 at 20:16
  • Sorry, didn't see that - probably should have mentioned it up front. You don't have enough rep to comment at the moment, but if you did first commenting on the original poster of the script's answer for help would be the best thing to do, and then asking a new question if you got no response.
    – Chris W
    Commented Jun 10, 2015 at 20:24
  • 1
    Here's an opinion of why this might not be possible to do with any confidence: gisnuts.com/terra/blog/2014/02/24/… I tested your code on an mxd saved in 10.2.2, and got "could not be determined". I tested this code: snorf.net/blog/2015/04/15/… And it told me my version saved in 10.2.2 was 10.1. Commented Jun 10, 2015 at 20:32
  • Ah surprised I didn't see that site beforehand. I can't use OleFileIO_PL module in my case sadly. Guess this is all I can do for now. Thanks guys.
    – Sharm
    Commented Jun 10, 2015 at 20:42
  • I find it odd that for most peoples case it is usually around 50/50. It either shows up or it doesn't.
    – Sharm
    Commented Jun 11, 2015 at 12:28

1 Answer 1


What you are after may not be determinable, it requires that the document info was saved/embedded and as you've found that is not often embedded into the document. I cannot find any reference to when this data is saved/skipped. For what it's worth this is another method:

import os, sys, arcpy
from comtypes.client import GetModule, CreateObject
BasePath = sys.argv[1]
# read http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python
# read it CAREFULLY and follow the links, there's more information needed on the links

m = GetModule(r'C:\Your path\Desktop10.1\com\esriCarto.olb') # change as needed
import comtypes.gen.esriCarto as esriCarto
mapObj = CreateObject(esriCarto.MapDocument ,interface=esriCarto.IMapDocument)

for xPath, xDirs, xFiles in os.walk(BasePath):
    for ThisFile in xFiles:
        fName, fExt = os.path.splitext(ThisFile)
        if fExt.upper() == ".MXD":
            verInf = mapObj.GetVersionInfo()
            if verInf[0]:
                arcpy.AddMessage("Version info missing : %s" % ThisFile)
                arcpy.AddMessage("%s is version %d.%d" %(ThisFile,verInf[1],verInf[2]))

This uses COM types and the IMapDocument.GetVersionInfo interface in python; as I have discovered only about half of my map documents have this metadata attached to them. This however does expose another interface IMapDocument.DocumentVersion which, when it returns a value of 0 means the MapDocument can be opened and 1 or 2 if it can't.. at least you can decide if the MXD can be opened with the current version of ArcMap (value=0) or is a future version (value=1) or the MXD is likely to be broken (value=2).

  • The thing is I can not install anything on the users computer. From what I read I would need to install comtypes and set it up.
    – Sharm
    Commented Jun 11, 2015 at 12:27
  • 1
    Yes, you need to setup ComTypes for this to work. The other option is to download Visual Studio Express 2010 (or suitable for ArcGis SDK) and write it in C# or VB.net then compile to an exe. If you need help with that code please post as a separate question. Commented Jun 11, 2015 at 21:53
  • Instead of making a new question can you just point me to a link so I can attempt this on my own? Do not think I can get much help when I have nothing to start off of.
    – Sharm
    Commented Jun 12, 2015 at 12:14
  • If you are not fluent in VB.net or C# you have a lot of work ahead.. Google Visual Studio Express 2010 for download (install and register), install the SDK from your install media then read help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/… as for the code sample it's all there in the python (with a few more steps): create a new IMapDocument, open your MXD then interrogate the returned value... the hard part is iterating your folder (see msdn.microsoft.com/en-us/library/bb513869.aspx) Commented Jun 14, 2015 at 22:03
  • You can get install folder r'C:\Your path\Desktop10.1\com\esriCarto.olb' from the Windows environment variable AGSDESKTOPJAVA set by the ArcMap install, for example: AGSDESKTOPJAVA=C:\Program Files (x86)\ArcGIS\Desktop10.8 or from the dictionary: arcpy.GetInstallInfo('desktop')["InstallDir"] Commented Aug 14, 2021 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.