chris.stump

findAndReplaceWorkspacePaths doesn't work w/multiple data frames in mxd??

Discussion created by chris.stump on Aug 30, 2012
Latest reply on Sep 4, 2012 by jbarrette-esristaff
Hello all,

Got stuck trying to fix broken links in a series of mxds.  I found if a map has more than one data frame, the findandreplaceworkspacepaths method is not working, or at least the mxd.save() call isn't saving the changes, even though the code runs without error.  Even if I ran code similar below through the arcpy window using the 'current' map object call, and clicking the save icon in ArcMap or performing File->Save from the File menu in ArcMap does not save any changes.  Once I removed all but one data frame from an mxd, the code and all save/save as operations worked fine.  Is this a bug, or am I doing something wrong?  Thanks ahead of time.  I'm using ArcGIS v10sp4, and am just trying to change shapefile workspace paths in an mxd. 

Here is a quick code sample: 
import arcpy
mxd = arcpy.mapping.MapDocument(r'\\filelocation\map.mxd')
mxd.findAndReplaceWorkspacePaths(r'\\filelocation1', r'\\filelocation2')
arcpy.RefreshTOC
mxd.save()
del mxd

Outcomes