Hi there -
I just want to start off by saying I am fairly new to using Arcpy, so any input on this issue is appreciated.
I am trying to automate the process of importing .mxd files to .aprx since ArcMap is going away in 2026. I have been able to successfully import the .mxd file to a .aprx using importDocument(), but I am struggling to open the Map that was imported into the .aprx's 'Project' tab in the Catalog. To open the Map, I have been trying to use .openView, but I keep getting this error:
AttributeError: 'ArcGISProject' object has no attribute 'openView'
I am using Arcpy 3 if that is helpful to know. Ultimately, I want the Python script to import the .mxd file to the .aprx file, and when my colleagues in my organization open the new .aprx file, the map that was imported from their .mxd file will already be open.
Here is my code:
import arcpy, os
#Parameters
mxd_input = arcpy.GetParameterAsText(0)
outputlocation = arcpy.GetParameterAsText(1)
aprx_name = arcpy.GetParameterAsText(2)
#Define.aprx blank map
aprx = arcpy.mp.ArcGISProject(r"Path_To_Blank_APRX")
#Save a copy of a blank ArcPro .aprx file with the aprx file name the user provided
aprx.saveACopy(os.path.join(outputlocation, (aprx_name + ".aprx")))
#Import the .mxd file specified by the user in to the new .aprx file
aprx.importDocument(mxd_input)
#Open Map in .aprx
aprx.listMaps({})
aprx.openView()
#Re-save map
aprx.saveACopy(os.path.join(outputlocation, (aprx_name + ".aprx"))
Thank you in advance!
Have you performed the manual process of importing mxds into a new aprx?
I ask because not all elements from ArcMap get imported correctly into Pro so you would most likely have cleanup. Legends in layouts do not always import correctly so that is at least one area to look out for especially for more complex legends.
I have done the manual process of importing mxds and am aware of the cleanup. Unfortunately, my colleagues have tons of mxd template files that we want to import to ArcPro, so this will be the first step to doing that. They are going to have to do the cleanup afterwards haha
Thanks for the comment!