frankv3

help with text element

Discussion created by frankv3 on Mar 31, 2011
Latest reply on Mar 31, 2011 by frankv3
updating a text element in an mxd is not working for me
ArcGIS 10 - 10.1.2800
there is a text string element in the mxd "SHEET   3002" that i want to change based on a variable
this was tested on an mxd that only has this text element in it and nothing else

this is the code to change the text element it that is not working:

import arcpy
import arcpy.mapping
MXD = arcpy.mapping.MapDocument("CURRENT")
for SheetNum in arcpy.mapping.ListLayoutElements(MXD, "TEXT_ELEMENT", "SHEET*"):
    SheetNum.text = "SHEET   7001"


if the code is:
import arcpy
import arcpy.mapping
MXD = arcpy.mapping.MapDocument("CURRENT")
for SheetNum in arcpy.mapping.ListLayoutElements(MXD, "TEXT_ELEMENT", "SHEET*"):
   if SheetNum.type == "TEXT_ELEMENT":
       SheetNum.text = "SHEET   7001"

still nothing happens

if i try:
SheetNum = arcpy.mapping.ListLayoutElements(MXD, "TEXT_ELEMENT", "SHEET*")[0]

it returns:
Runtime error <type 'exceptions.IndexError'>: list index out of range

what is wrong with this?

Outcomes