How to Delete a text element (text box) in an mxd?

801
2
06-09-2011 09:09 AM
MikeMacRae
Frequent Contributor
I am creating a program to run through a number of mxd's to change some text elements for final delivery to my client. In the process, I want to delete a text element that says "DRAFT" in each .mxd when the program runs.

for textElement in arcpy.mapping.ListLayoutElements(mxd2, "TEXT_ELEMENT"):

    if textElement.text == "DRAFT": 
        del textElement
    else:
        print "No DRAFT"


I tried del textElement and textElement.delete, neither seem to work.

I also tried setting the text box to nothing (ie textElement.text = "") but I need to actually get rid of the text box.

Thanks for any help,
Mike
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Honored Contributor
FYI

http://forums.arcgis.com/threads/26979-Deleting-Layout-Elements-with-arcpy.mapping

Closest thing you can do is set height/width to zero.
0 Kudos
MikeMacRae
Frequent Contributor
Thanks for the response Matthew. Looks like I am setting it to " "

Cheers,
Mike
0 Kudos