Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm wondering if you can lift the name of a layer in the ToC (within a group) and use it in dynamic text.

Is there existing syntax to do this?
Perhaps ...

<dyn type="ToC" property="activeLayer"/>

Using ArcMap 10 sp3.

share|improve this question
I also have the same problem at the moment. Unfortunately, I haven't found anything in the ArcGIS Resource Center, yet. Verena –  user5359 Jan 4 '12 at 14:06
What exactly do you mean by "dynamic text"? Are you looking to use the layer name in or as a text element on the map? –  ericoneal Jan 4 '12 at 14:20
For my purpose, yes! I have several layers and I want the name of each layer being displayed on the map (depending on the active layer). –  user5359 Jan 4 '12 at 15:34
This could be done with Python, but I doubt it's ideal for your project unless it's a large one across multiple map documents. If that is the case, I can post a solution since I have some code that does something similar. –  nicksan Jan 10 '12 at 19:03

1 Answer 1

You could write a python script that uses the following mapping modules:

import arcpy

mxd = arcpy.mapping.MapDocument("Current")

for lyr in arcpy.mapping.ListLayers(mxd):
     if lyr == 'yourlayername':

for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
     if elm.text == "defaulttext":
        elm.text = lyr # change layout text
share|improve this answer
I am interested in the python code. I'd like to be able to do the same thing. I have a clunky solution right now, but I'd like to see how you looped the the layer list and stored each unique layer name in a list to then add to text elements in the mxd. –  user8478 Jun 27 '12 at 17:23
@Derek, Please post a separate question if you have a specific question about this code snippet. –  artwork21 Jun 28 '12 at 11:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.