Working with dynamic text

Dynamic text is text placed on a map layout that changes dynamically based on the current properties of the map document, data frame, and Data Driven Pages. Dynamic text works through the use of tags, like HTML. Here is an example of a dynamic text tag for the title of a map document:

<dyn type="document" property="title"/>

The actual text you will see on the map layout would be the actual map title defined in Map Document Properties. Dynamic text can be added to a map layout by either adding one of the text elements listed under Insert on the main menu or editing an existing text element by manually adding a dynamic tag.

Some dynamic text can be quite simple and be used by itself, while some may be quite complex. In some cases, you might want to combine dynamic text with static text. For example, here is dynamic text showing the last date the map was saved:

Date Saved: <dyn type="document" property="date saved" format="short"/> <dyn type="document" property="time saved" format=""/>

There are two parts to this: static text (Date Saved:), signifying what the text is about, and the dynamic tags <dyn type="document" property="date saved" format="short"/> <dyn type="document" property="time saved" format=""/>. Within the dynamic tags, there are the dynamic text type (dyn type="document"), the type property (property="date saved"), and format information (format="short").

TipTip:

You can use formatting tags and other universal modifiers, such as emptyStr, preStr, and postStr, to further customize your dynamic text.

If the dynamic text you are adding to your layout is too long and you want to enter a line break, you can do this by editing the attribute field in the table by using SHIFT+ENTER.

Learn more about keyboard shortcuts for working with tables

Adding dynamic text from the main menu

A number of preformatted dynamic text types can be added directly to the map layout. You can do this by clicking Insert > Dynamic Text on the main menu. Those listed are only a subset of dynamic text types. You can access other dynamic text types by editing an existing text element. See below for a complete list of dynamic text types.

The following dynamic text elements can be added directly from the main menu:

Editing dynamic text

Editing existing text elements to include dynamic text tags can be an easy way to create very useful elements on your map layout.

For example, perhaps you had a map that several people access to edit and you wanted to keep track of who worked with it last and when. The text on the layout may look like this: "Last Updated by Jane on 7/18/2010 at 9:56 AM." This can be accomplished by editing an existing text element such that you string together static text with dynamic text tags for "user", "date", and "time". The text for the text element would look like this:

Last updated by: <dyn type="user"/> on <dyn type="date" format="short"/> at <dyn type="time" format=""/>

You can further customize the look of the text by using formatting tags to change the font or color of the text or use the attributes of the date and time dynamic text types to customize how these values are returned. See below for more information on working with date and time.

CautionCaution:

If dynamic text is copied and pasted into the data frame or the .mxd is saved to a version of ArcMap prior to 10, it will become realized. Realized means that the text is no longer dynamic. For example, the following dynamic text used to capture the given date:

Date:<dyn type="date" format"short"/>

would become static text with the current date, for example,

Date:4/4/2009.

Learn more about formatting tags available in ArcMap

Empty strings

If a dynamic text element string parses to nothing, you will see [empty] displayed on the layout. When the layout is exported or printed, [empty] text elements are dropped. You will not see these in your output. Displaying them in the layout view lets you know that a text element is present, but the value the dynamic tag is referring to is currently null.

The entire text element string is evaluated. For example, if you have the following text:

Map Credits: <dyn type="document" property="name"/>"

and the document doesn't have credit information, you'll still see Map Credits: on the layout because the parsed text element string is not blank. It has static text in it. If you export or print the map, Map Credits: will appear on the map. On the other hand, if you have the following text:

<dyn type="document" property="name"/>"

you will see [empty] on the display because the parsed text element string is blank. This will not be displayed when exporting or printing the map.

If you want a different value to be displayed when a string is empty, you can add the tag emptyStr="<text>". The emptyStr attribute lets you specify text to display if a single dynamic tag parses to blank. For example, consider the following tag:

<dyn type="document" property="credits"/>

If the map document contains no credit information (available on Map Document Properties), the result on the layout would be [empty]. By using the empty attribute, you can have default text when there is no information available. The text would look something like this:

<dyn type="document" property="credits" emptyStr="There are no credits for this map."/>

The result on the layout would look like this: "There are no credits for this map." This text would be displayed on the exported or printed map.

Working with date dynamic text

There is a variety of date formats available that can be used independently or in combination. If used in combination, any spaces used to separate each format element appear in the output string. The format is case sensitive. They must be in uppercase or lowercase as shown in the table, for example, MM, not mm. Characters in the format string that are enclosed in single quotation marks appear in the same location and unchanged in the output string.

For example, the tag

<dyn type="date" format="ddd MMM yy"/>

returns Thu Sep 09.

Date formats

Format

Description

Example syntax

Example output

short

Month, day, and year as digits with no leading zero for single-digit days.

<dyn type="date" format="short"/>

9/7/2009

long

Month and day as text with year.

<dyn type="date" format="long"/>

Thursday, September 7, 2009

month

Month as text with year.

<dyn type="date" format="month"/>

September, 2009

d

Day of month as digits with no leading zero for single-digit days.

<dyn type="date" format="d"/>

7

dd

Day of month as digits with leading zero for single-digit days.

<dyn type="date" format="dd"/>

07

ddd

Day of week as a three-letter abbreviation. The function uses the LOCALE_SABBREVDAYNAME value associated with the specified locale.

<dyn type="date" format="ddd"/>

Thu

dddd

Day of week as its full name. The function uses the LOCALE_SDAYNAME value associated with the specified locale.

<dyn type="date" format="dddd"/>

Thursday

M

Month as digits with no leading zero for single-digit months.

<dyn type="date" format="M"/>

9

MM

Month as digits with leading zero for single-digit months.

<dyn type="date" format="MM"/>

09

MMM

Month as a three-letter abbreviation. The function uses the LOCALE_SABBREVMONTHNAME value associated with the specified locale.

<dyn type="date" format="MMM"/>

Sep

MMMM

Month as its full name. The function uses the LOCALE_SMONTHNAME value associated with the specified locale.

<dyn type="date" format="MMMM"/>

September

y

Year as last two digits, but with no leading zero for years less than 10.

<dyn type="date" format="y"/>

9

yy

Year as last two digits, but with leading zero for years less than 10.

<dyn type="date" format="yy"/>

09

yyyy

or

yyyyy

Year represented by full four or five digits, depending on the calendar used. Thai Buddhist and Korean calendars both have five-digit years. The yyyy pattern will show five digits for these two calendars and four digits for all other supported calendars.

<dyn type="date" format="yyy"/>

2009

gg

Period/Era string. The function uses the CAL_SERASTRING value associated with the specified locale. This element is ignored if the date to be formatted does not have an associated era or period string.

<dyn type="date" format="gg"/>

Working with time dynamic text

There is a variety of date formats available that can be used independently or in combination. If used in combination, any spaces used to separate each format element appear in the output string. The format is case sensitive. They must be in uppercase or lowercase as shown in the table, for example, ss, not SS. Characters in the format string that are enclosed in single quotation marks appear in the same location and unchanged in the output string.

For example, the tag

Time: <dyn type="time" format= "HH:mm tt"/>

returns 09:24 AM.

Time formats

Format

Description

Example syntax

Example output

empty

Hour, minutes, and seconds with no leading zero for single-digit hours; 12-hour clock

<dyn type="time" format=""/>

3:04:09 PM

h

Hour with no leading zero for single-digit hours; 12-hour clock

<dyn type="time" format="h"/>

3

H

Hour with no leading zero for single-digit hours; 24-hour clock

<dyn type="time" format="H"/>

15

hh

Hours with leading zero for single-digit hours; 12-hour clock

<dyn type="time" format="hh"/>

03

HH

Hours with leading zero for single-digit hours; 24-hour clock

<dyn type="time" format="HH"/>

15

m

Minutes with no leading zero for single-digit minutes

<dyn type="time" format="m"/>

4

mm

Minutes with leading zero for single-digit minutes

<dyn type="time" format="mm"/>

04

s

Seconds with no leading zero for single-digit seconds

<dyn type="time" format="s"/>

9

ss

Seconds with leading zero for single-digit seconds

<dyn type="time" format="ss"/>

09

t

One-character time marker string, such as A or P

<dyn type="time" format="t"/>

P

tt

Multicharacter time marker string, such as AM or PM

<dyn type="time" format="tt"/>

PM

Dynamic text available in ArcMap

There are also a number of tags not available directly from the main menu. These tags are listed in the tables below. If you want to add these to your map layout, you will need to add them to an existing text element. Simply add a text element, open its properties, and begin editing. You can also customize your dynamic text by using formatting tags.

The following tables specify the dynamic text available in ArcMap:

General dynamic text

Description

Example syntax

Note

Computer Name

<dyn type="computer"/>

Must be added manually.

User Name

<dyn type="user"/>

Available from the main menu.

Current Date

Date: <dyn type="date" format="short"/>

Available from the main menu. Date dynamic text can be further formatted. See the Working with date dynamic text section in this help topic for more information.

Current Time

Time: <dyn type="time" format=""/>

Available from the main menu. Time dynamic text can be further formatted. See the Working with time dynamic text section in this help topic for more information.

Map document dynamic text

Description

Example syntax

Note

Title

<dyn type="document" property="title"/>

Available from the main menu.

Summary

<dyn type="document" property="summary"/>

Must be added manually.

Author

<dyn type="document" property="author"/>

Available from the main menu.

Category

<dyn type="document" property="category"/>

Must be added manually.

Description

<dyn type="document" property="description"/>

Must be added manually.

Tags

<dyn type="document" property="tags"/>

Must be added manually.

Hyperlink Base

<dyn type="document" property="hyperlinkBase"/>

Must be added manually.

Credits

<dyn type="document" property="credits"/>

Must be added manually.

Document Name

<dyn type="document" property="name"/>

Available from the main menu.

Path

<dyn type="document" property="path"/>

Must be added manually. Path includes the map document name.

Service Layer Credits

Path: <dyn type="document" property="service layer credits" separator="\n"/>

Available from the main menu. This is the attribution/credits of ArcGIS for Server and third-party tiled service layers.

Folder

<dyn type="document" property="folder"/>

Must be added manually. This is the folder where the map document is located. It is the path without the document name.

Date Saved

<dyn type="document" property="date saved" format="short"/> <dyn type="document" property="time saved" format=""/>

Available from the main menu. You can use the "date saved" and "time saved" tags together, as in the example, or you can use them separately.

Date Printed

<dyn type="document" property="date printed" dateFormat="MM dd yy"/>

Must be added manually.

Date Exported

<dyn type="document" property="date exported" dateFormat="MM dd yy"/>

Must be added manually.

Data frame dynamic text

Description

Example syntax

Note

Coordinate System

Available from the main menu. The default tag includes all the coordinate parameters of the data frame and can be quite large. See the next table for access to the individual coordinate system elements.

Credits

<dyn type="dataFrame" name="DataFrameName" property="credits"/>

Must be added manually.

Data Frame Name

<dyn type="dataFrame" name="DataFrameName" property="name"/>

Available from the main menu.

This is the name of the identified data frame as specified on the Data Frame Properties dialog box. The current name of the data frame is identified by the name attribute: name="Current name of data frame". This attribute is the link between the dynamic text element and a specific data frame. The text string value of this attribute is updated every time the data frame's name changes, along with the dynamic text.

However, if this name attribute value does not match the current name of any of the map's data frames, the dynamic text element (property="name") uses the name of the active data frame by default. The text string value of the name attribute (name="Unmatched name") remains the same. It will not use the name of the default data frame. It will retain the mismatched text until you manually change this value to match the name of a data frame or change the name of a data frame to match it. This allows you to enter a bogus name in the name attribute, for example, Name: <dyn type="dataFrame" name="UseActiveDataFrameName" property="name"/>, in order to have the dynamic text element use only the name of the active data frame and not be tied to any specific data frame.

Description

<dyn type="dataFrame" name="DataFrameName" property="description"/>

Must be added manually.

Distance Units

<dyn type="dataFrame" name="DataFrameName" property="distance units"/>

Available from the main menu.

Map Units

<dyn type="dataFrame" name="DataFrameName" property="units"/>

Must be added manually.

Reference Scale

<dyn type="dataFrame" name="DataFrameName" property="reference scale"/>

Available from the main menu.

Rotation

<dyn type="dataFrame" name="DataFrameName" property="rotation"/>

Must be added manually.

Scale

<dyn type="dataFrame" name="DataFrameName" property="scale"/>

Can be added manually as dynamic text or using the Scale Text option on the Insert menu.

Start Time

<dyn type="dataFrame" name="DataFrameName" property="start time"/>

This is the start time as defined by the time extent of the time slider. It must be added manually. If you do not see a value for time, you will need to initialize this by opening the Time Slider window. If time includes both a date and time element, you can append .date or .time after the property to get a specific element. For example, you can use property = "starttime.date". This would return only the date element of the start time. Its format is specified on the Time Slider Options dialog box. You can override this format by applying a format element in your dynamic text tag such as property="time.date" format = "long", which would return the date in long format.

Time

<dyn type="dataFrame" name="DataFrameName" property="time"/>

This is the current data frame time as defined by the time slider. It is available from the main menu. If you do not see a value for time, you will need to initialize this by opening the Time Slider window. If time includes both a date and time element, you can append .date or .time after the property to get a specific element. For example, you can use property = "starttime.date". This would return only the date element of the start time. Its format is specified on the Time Slider Options dialog box. You can override this format by applying a format element in your dynamic text tag such as property="time.date" format = "long", which would return the date in long format.

End Time

<dyn type="dataFrame" name="DataFrameName" property="end time"/>

This is the end time as defined by the time extent of the time slider. It must be added manually. If you do not see a value for time, you will need to initialize this by opening the Time Slider window. If time includes both a date and time element, you can append .date or .time after the property to get a specific element. For example, you can use property = "starttime.date". This would return only the date element of the start time. Its format is specified on the Time Slider Options dialog box. You can override this format by applying a format element in your dynamic text tag such as property="time.date" format = "long", which would return the date in long format.

When you create a dynamic text tag for a specified data frame, the data frame will be referenced by the name it has when the tag is created. For example, if the current active data frame is named My Map and you insert a dynamic text element for the data frame's description, the tag will be

<dyn type="dataFrame" name="My Map" property="description"/>.

If you later rename the data frame in the table of contents or through the Properties dialog box, the tag automatically updates to reflect this change. For example, if you change the data frame name from My Map to City Map, the existing data frame dynamic text tags will automatically change to

<dyn type="dataFrame" name="City Map" property="description"/>.

CautionCaution:
Since data frame tags are referenced by data frame name, it is not recommended that you have two or more data frames with the same name. Dynamic text will only be able to refer to one of them.

Coordinate system dynamic text

Description

Example syntax

Note

Upper Left Corner

<dyn type="dataFrame" name="DataFrameName" property="upperLeft" units="dms" decimalPlaces="4"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Upper Midpoint

<dyn type="dataFrame" name="DataFrameName" property="upperMid" units="ddm" decimalPlaces="2"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Upper Right

<dyn type="dataFrame" name="DataFrameName" property="upperRight"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Left Midpoint

<dyn type="dataFrame" name="DataFrameName" property="midLeft"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Center

<dyn type="dataFrame" name="DataFrameName" property="center"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Right Midpoint

<dyn type="dataFrame" name="DataFrameName" property="midRight"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Lower Left Corner

<dyn type="dataFrame" name="DataFrameName" property="lowerLeft"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Lower Midpoint

<dyn type="dataFrame" name="DataFrameName" property="lowerMid"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Lower Right Corner

<dyn type="dataFrame" name="DataFrameName" property="lowerRight"/>

Must be added manually. The syntax example returns a coordinate pair. If you want only one of the coordinates, append .x or .y after the position, for example, upperLeft.x or center.y.

Projected Coordinate System

<dyn type="dataFrame" name="Layers" property="spatialReference" srProperty=" pcs"/>

Must be added manually.

Geographic Coordinate System

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty=" gcs"/>

Must be added manually.

Datum

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="datum"/>

Must be added manually.

Projection

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="projection"/>

Must be added manually.

Remarks

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="remarks"/>

Must be added manually.

Central Meridian

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "centralMeridian" units="dms" decimalPlaces="2"/>

Must be added manually.

Latitude of Origin

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "latitudeOfOrigin" units="dms" decimalPlaces="2"/>

Must be added manually.

Longitude of Origin

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "longitudeOfOrigin" units="dms" decimalPlaces="2"/>

Must be added manually.

Latitude of Center

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "latitudeOfCenter" units="dms" decimalPlaces="2"/>

Must be added manually.

Longitude of Center

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "longitudeOfCenter" units="dms" decimalPlaces="2"/>

Must be added manually.

Latitude of 1st

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "latitudeOf1st" units="dms" decimalPlaces="2"/>

Must be added manually.

Latitude of 2nd

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "latitudeOf2nd" units="dms" decimalPlaces="2"/>

Must be added manually.

Longitude of 1st

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "longitudeOf1st" units="dms" decimalPlaces="2"/>

Must be added manually.

Longitude of 2nd

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "longitudeOf2nd" units="dms" decimalPlaces="2"/>

Must be added manually.

False Easting

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="falseEasting" units="dms" decimalPlaces="2"/>

Must be added manually.

False Northing

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "falseNorthing" units="dms" decimalPlaces="2"/>

Must be added manually.

Standard Parallel 1

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "standardParallel1" units="dms" decimalPlaces="2"/>

Must be added manually.

Standard Parallel 2

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty= "standardParallel2" units="dms" decimalPlaces="2"/>

Must be added manually.

Scale Factor

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="scaleFactor" decimalPlaces="2"/>

Must be added manually.

Azimuth

<dyn type="dataFrame" name="DataFrameName" property="spatialReference" srProperty="azimuth" decimalPlaces="2"/>

Must be added manually.

Page

Description

Example syntax

Note

Page Name

<dyn type="page" property="name"/>

Available from the main menu or the Data Driven Pages toolbar. This corresponds to the current value of the attribute field set as the Data Driven Pages name field.

Page Number

<dyn type="page" property="number"/>

Available from the main menu or the Data Driven Pages toolbar. This corresponds to the current value of the attribute field set as the data-driven page number. If no page number field is specified, the pages will be numbered in increments of 1 starting with the value set as the starting page number.

Page Index

<dyn type="page" property="index"/>

Must be added manually. Page index ignores page number field values along with the starting page number. For example, you could have 10 data-driven pages and set the starting page number to 3. Page index will report 1 for the first page.

Page Count

<dyn type="page" property="count"/>

Must be added manually. This is the total count of data-driven pages.

Neighbor or Adjacent Page

<dyn type="page" property="PageNumber_NW"/>

Must be added manually and is based on field name. In this example, the tag is pulling from a field named PageNumber_NW. This field is reporting the name of the adjacent page to the northwest of the current page.

If your index layer is a regular grid, you can use the geoprocessing tool Calculate Adjacent Fields to create the fields.

Index layer (data-driven page) attribute

<dyn type="page" property="attribute" field="<Field Name>" domainlookup="true"/>

Available from the main menu or the Data Driven Pages toolbar. This corresponds to the current value of a selected attribute of the index layer for the given data-driven page. This includes fields joined to the index layer.

Index layer (data-driven page) display expression

Page <dyn type="page" property="expression"/>

Available from the main menu or the Data Driven Pages toolbar. This corresponds to the current value of the Display Expression set on the Display tab of the Layer Properties dialog box.

Learn more about using dynamic text with Data Driven Pages

How to add dynamic text from the main menu

  1. Click Insert > Dynamic Text on the main menu.
  2. Choose the dynamic text you want to add from the pull-right menu.
  3. Click the Select Elements tool Select Elements on the Draw toolbar, double-click the text element, then drag it to the location you want it on the page layout.

How to add dynamic text not available from the main menu

  1. Click Insert > Dynamic Text on the main menu.
  2. Choose any dynamic text from the pull-right menu.

    You will be editing the text element after you add it to the page layout.

  3. Click the Select Elements tool Select Elements on the Draw toolbar and double-click the text element you just added.
  4. Replace the text shown in the Text box on the Text tab with the text (and tags) that you want to use. You might want to consider copying from the syntax examples above and pasting this directly into the text input box. Make sure you include the entire tag (< to >).

How to edit dynamic text

  1. Click the Select Elements tool Select Elements on the Draw toolbar and double-click the text element you want to edit.
  2. Replace the text shown in the Text box on the Text tab with the text (and tags) that you want to use. You might want to consider copying directly from the syntax examples above and pasting this into the text input box. Make sure you include the entire tag (< to >).

Related Topics

2/12/2013