it only works searcing with actual string. can't find the text when i use * . changing date and path strings, so they're not all the same.
ex.
for dA in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if dA.text == 'DATE: 10/10/2011':
dA.text = 'Date: <dyn type="date" format=""/>' THIS WORKS
for fp in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if fp.text == 'FILE: *':
fp.text = 'Document Path: <dyn type="document" property="path"/>' THIS DOESN'T WORK
Thanks in advance for any ideas.
Pete
Solved! Go to Solution.
Maybe try the reverse logic to this.
Using the in operater you can check if a string contains a subtring, that way you don't need a wildcard
for fp in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if 'FILE: ' in fp.text:
fp.text = 'Document Path: <dyn type="document" property="path"/>'
http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method
Maybe try the reverse logic to this.
Using the in operater you can check if a string contains a subtring, that way you don't need a wildcard
for fp in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if 'FILE: ' in fp.text:
fp.text = 'Document Path: <dyn type="document" property="path"/>'
http://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method
Thanks to BOTH responses. It worked beautifully!!
... or:
if fp.text.startswith('FILE: '):
Thanks to BOTH responses. It worked beautifully!!
Can you please mark the question as answered?