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.

  • 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

I use a workaround that has functioned fairly well. I use MXDs to prepare multiple printable maps (in a single MXD) frequently. Typically I'm showing the same bookmark/extent and have consistent background data, BUT want to swap out and highlight specific features in differently named maps. To create a fake dynamic title I add a separate Legend from the one I use to show actual symbology, and just show the Layer Name text. Here are my steps:

  1. Add dummy shapefile/feature class (ex. - I use the county boundary of a single county, or the single largest geography I happen to be working with)
  2. Make the symbology of the dummy file no color with no outline
  3. Add Layer Name/ Heading info that is appropriate for your 'dynamic text' - in my case it will represent the figure number/ title
  4. Add a new Legend that will ONLY contain dummy files (aka your title/dynamic text)
  5. Add your dummy files to the new Legend
  6. To keep text alignment reasonable, make the default patch size 0.000001 ( or some small number) - you will not be allowed to make the patch size exactly 0
  7. In the General Legend tab make sure to 'Only display layers that are checked in the TOC' and it helps to uncheck the 'Add new item to the legend when a new layer is added to the map'

I created several MXDs where I used this technique not only to display a 'dynamic title', but also dynamic text such as the 'data source' and 'map prepared by' information. For each of the fake dynamic text features, I utilized a dummy shapefile (no fill/ no outline) and grouped that dummy with any relevant shapefiles/symbology intended for an individual printable map. The MXD can get very large and can get clunky, but you're ensured that basemap data ALWAYS looks the same (you don't have to modify labels/symbology in many MXDs that show the same overall viewport, because it's all saved in a single MXD).


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.name == 'yourlayername':

for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
     if elm.text == "defaulttext":
        elm.text = lyr.name # change layout text
  • 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
  • +1 This is the coding pattern that forms the basis of what I call pseudo dynamic text. – PolyGeo Nov 4 '15 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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