I try to change the font size and the element xy position of text element for several maps. Right now the font size is 21.79 and the xy position is:
elm.elementPositionX = 8.204
elm.elementPositionY = 26.596
I try this code:
import arcpy
mxd = arcpy.mapping.MapDocument(r"G:\desktop\Project\project.mxd")
for elm in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT"):
if elm.text == "data1":
elm.fontSize = 16
elm.elementPositionX = 9.898
elm.elementPositionY = 27.649
mxd.save()
del mxd
The code above works fine when i run for one map but when i loop it on several maps the code does not work:
import arcpy, os, sys
from arcpy import env
env.workspace = r"G:\desktop\Project"
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"G:\desktop\Project\\" + mxdname)
for elm in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT"):
if elm.text == "data1":
elm.fontSize = 16
elm.elementPositionX = 9.898
elm.elementPositionY = 27.649
print 'elementPosition changed'
mxd.save()
del mxd

