Python Add-In Button: saveACopy

Discussion created by Phil345 on Sep 27, 2012
Latest reply on Sep 27, 2012 by arekmatoszka
I am trying to create a button that will convert a mxd file from v10.1 to v9.3 using the saveACopy function. However, I am having
trouble getting the button to work properly, but am also unsure of my code. The code I currently have added will run through a
toolbox as a batch. If anyone has any ideas or a fix to help me complete this button it would be greatly appreciated. The code is
as follows:

note: everything after "def onClick(self): is the code I have written

import arcpy
import pythonaddins
import os
import sys
import string

class SaveACopy(object):
    """Implementation for PythonAddIn_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False
    def onClick(self):
        #param = arcpy.GetParameterAsText(0)

        #outloc = arcpy.GetParameterAsText(1)

        mxd = arcpy.mapping.MapDocument(param)

        base = os.path.basename(param)

        arcpy.AddMessage(outloc + os.sep + base + "_v93")

        mxd.saveACopy(outloc + os.sep + base[:-4] + "_v93.mxd", "9.3")

        #the final parameter above may be changed to 8.3, 9.0, 9.2, 9.3, or 10, depending on users