<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Change text using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262554#M20208</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic python question here!, you just get the mxd names, as the if statement is never satisfied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To resolve, try changing your code as follows, then you should be able to work out what has happened!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy&amp;nbsp; 
from arcpy import env&amp;nbsp;&amp;nbsp; 
&amp;nbsp; 
env.workspace = r"D:\PROJECTS\ab\gis"&amp;nbsp; 
counter = 0&amp;nbsp; 
for mxdname in arcpy.ListFiles("*.mxd"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = 'land use'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + '\n'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + 'fuel'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"D:\PROJECTS\ab\gis\\" + mxdname)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = 'free fuel'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + '\n'&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + 'gas'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "We are looking for a value of: "
&amp;nbsp;&amp;nbsp;&amp;nbsp; print oldText
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == oldText:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print elm.name&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = myString
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Non Matching Element value of:"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print elm.text
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1&amp;nbsp; 
del mxd&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:52:46 GMT</pubDate>
    <dc:creator>LukeWebb</dc:creator>
    <dc:date>2021-12-11T12:52:46Z</dc:date>
    <item>
      <title>Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262549#M20203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; there,&lt;/P&gt;&lt;P&gt;i try to change oldText with myString in 25 mxd's ( in the layout ).&lt;/P&gt;&lt;P&gt;The text (i used draw tool to create it) contain 2 row:&lt;/P&gt;&lt;P&gt;land use&lt;/P&gt;&lt;P&gt;fuel&lt;/P&gt;&lt;P&gt;myString is the new text &lt;/P&gt;&lt;P&gt;i try this code but python only print list of mxd names in the folder:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env 

env.workspace = r"D:\PROJECTS\ab\gis"
counter = 0
for mxdname in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = 'land use'
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + '\n'
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + 'fuel'
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"D:\PROJECTS\ab\gis\\" + mxdname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = 'free fuel'
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + '\n' 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + 'gas'
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == oldText :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print elm.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = myString
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1
del mxd&lt;/PRE&gt;&lt;P&gt;is it possible with python 2.7.8?&lt;/P&gt;&lt;P&gt;thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:52:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262549#M20203</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-11T12:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262550#M20204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;oldText = &lt;SPAN class="string"&gt;'land use'&lt;/SPAN&gt;&amp;nbsp; + &lt;SPAN class="string"&gt;'\n' + &lt;SPAN class="string"&gt;'fuel'&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; myString = &lt;SPAN class="string"&gt;'free fuel &lt;/SPAN&gt;+ &lt;SPAN class="string"&gt;'\n'&amp;nbsp; + &lt;/SPAN&gt; &lt;SPAN class="string"&gt;'gas' &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;show some output&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;it isn't a python issue&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 11:00:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262550#M20204</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-11T11:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262551#M20205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i get:&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;&lt;P&gt;environment 1.mxd&lt;/P&gt;&lt;P&gt;environment 2.mxd&lt;/P&gt;&lt;P&gt;environment 3.mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;til i get&lt;/P&gt;&lt;P&gt;environment 25.mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;&lt;P&gt;it only print mxd name&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 11:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262551#M20205</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2015-08-11T11:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262552#M20206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Print out the text elements without an if statement to ensure that your syntax for oldText is correct&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 12:31:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262552#M20206</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2015-08-11T12:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262553#M20207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;do you actually print out oldtext?&amp;nbsp; all you print out is&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;print&lt;/SPAN&gt; mxdname&amp;nbsp; &lt;/P&gt;&lt;P&gt;ergo you get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;environment 1.mxd&lt;/P&gt;&lt;P&gt;environment 2.mxd&lt;/P&gt;&lt;P&gt;environment 3.mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;til i get&lt;/P&gt;&lt;P&gt;environment 25.mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/P&gt;&lt;P&gt;it only print mxd name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put in print statements if you want to test stuff&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2015 14:11:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262553#M20207</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-11T14:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262554#M20208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic python question here!, you just get the mxd names, as the if statement is never satisfied.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To resolve, try changing your code as follows, then you should be able to work out what has happened!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy&amp;nbsp; 
from arcpy import env&amp;nbsp;&amp;nbsp; 
&amp;nbsp; 
env.workspace = r"D:\PROJECTS\ab\gis"&amp;nbsp; 
counter = 0&amp;nbsp; 
for mxdname in arcpy.ListFiles("*.mxd"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = 'land use'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + '\n'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = oldText + 'fuel'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"D:\PROJECTS\ab\gis\\" + mxdname)&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = 'free fuel'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + '\n'&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; myString = myString + 'gas'&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "We are looking for a value of: "
&amp;nbsp;&amp;nbsp;&amp;nbsp; print oldText
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == oldText:&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print elm.name&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = myString
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Non Matching Element value of:"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print elm.text
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save()&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; counter = counter + 1&amp;nbsp; 
del mxd&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:52:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262554#M20208</guid>
      <dc:creator>LukeWebb</dc:creator>
      <dc:date>2021-12-11T12:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262555#M20209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i will try-thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2015 05:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262555#M20209</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2015-08-12T05:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262556#M20210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i try your code Luke and got result :&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; 
environment 1.mxd
We are looking for a value of: 
land use
fuel
Non Matching Element value of:
land use
fuel
environment 2.mxd
We are looking for a value of: 
land use
fuel
&amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;P&gt;the oldText still remain the same in the layout :&lt;/P&gt;&lt;P&gt;&lt;IMG alt="1.jpg" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/121991_1.jpg" style="width: 620px; height: 497px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:52:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262556#M20210</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-11T12:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262557#M20211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;there is a couple of possibilities:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;the words 'land' or 'use' might containing leading or trailing spaces&lt;UL&gt;&lt;LI&gt;try "land " + "\nl" + "use"&lt;/LI&gt;&lt;LI&gt;or "land" + "\nl" + " use"&lt;/LI&gt;&lt;LI&gt;etc&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;what appears as one label stacked one over the other is actually &lt;STRONG&gt;two&lt;/STRONG&gt; labels... one called &lt;STRONG&gt;land&lt;/STRONG&gt; and the other called &lt;STRONG&gt;use&amp;nbsp; &lt;/STRONG&gt;To confirm...try clicking on the label in the map and see if one or both words get highlighted&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Aug 2015 06:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262557#M20211</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-08-12T06:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262558#M20212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To elaborate consider the following examples (not all combinations checked):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = "land" + "\nl" + "use"
&amp;gt;&amp;gt;&amp;gt; a == a
True
&amp;gt;&amp;gt;&amp;gt; # now try some variations
&amp;gt;&amp;gt;&amp;gt; b = "land " + "\nl" + "use"&amp;nbsp; # extra space after 'land'
&amp;gt;&amp;gt;&amp;gt; a == b
False
&amp;gt;&amp;gt;&amp;gt; c = "land" + "\nl" + "use "&amp;nbsp; # extra space after 'use'
&amp;gt;&amp;gt;&amp;gt; a == c
False
&amp;gt;&amp;gt;&amp;gt; d = "land" + "use"
&amp;gt;&amp;gt;&amp;gt; a == d
False&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:52:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262558#M20212</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T12:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Change text using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262559#M20213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for everyone,&lt;/P&gt;&lt;P&gt;finally i use this code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env 

env.workspace = r"&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;D:\PROJECTS\ab\gis&lt;/SPAN&gt;"
for mxdname in arcpy.ListFiles("*.mxd"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdname
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(r"&lt;SPAN style="color: #0000ff; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;D:\PROJECTS\ab\gis&lt;/SPAN&gt;\\" + mxdname)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oldText = 'land use\nfuel'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newText = u'free fuel\ngas'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.text == oldText:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = newText
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'elm.text changed'
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.save() 
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:52:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-text-using-arcpy/m-p/262559#M20213</guid>
      <dc:creator>Yaron_YosefCohen</dc:creator>
      <dc:date>2021-12-11T12:52:54Z</dc:date>
    </item>
  </channel>
</rss>

