rgthurau

arcpy.mapping replace multi-line text element

Discussion created by rgthurau on Dec 22, 2011
Latest reply on Dec 23, 2011 by jmward
Hi,
I'm trying to replace a word in a text element for many maps. My code effectively lists all maps, and all text elements, but the replacing part is not happening. I am wondering if it is because the element I am trying to replace is actually in three lines such as:

National Resources
Plan
Base

import arcpy

ws = arcpy.env.workspace = "X:\\Maps\\Draft4_BU\\"

MapList = arcpy.ListFiles("*.mxd")
for m in MapList:
    print m
    mxd = arcpy.mapping.MapDocument(ws + m)
    for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
        print elm.text
        if elm.text == "National Resources '/r/n' Plan '/r/n'Base":
            elm.text = "Natural Resources '/r/n' Plan '/r/n' Base"
    mxd.save()
    del mxd


Anyone have any ideas about how I can get this to work?

Thanks

Rich

Outcomes