Dynamic text
Dynamic text is text in a map layout that changes dynamically based on attributes of MPS-Atlas map sheets, cartographic elements such as feature layers and data frames, database objects such as tables, and system properties such as the date and time. The types of dynamic text available include feature layer, computer name, date and time, data frame, map sheet, or user name. Dynamic text can be used to place titles on your maps that automatically update, to create your own banners that include the user name, date, and time, or to place projection information such as the UTM zone.
When inserting dynamic text using the text box on the Dynamic Text Properties dialog box, you can combine both dynamic and regular, non-dynamic text within the text box and apply the available formatting options to customize the resulting text display. This can be used any time you want only part of the display text to update based on the current map sheet attributes while the rest of it remains the same.
For example, you can combine the non-dynamic text word Printed with the dynamic text date and time option so that every time the map sheet is printed, the text reads
Printed MM/dd/yy HH:mm:sswhere MM/dd/yy HH:mm:ss would be the current date and time.
In addition to the dynamic text element available in Production Mapping, ArcMap also has dynamic text font tags.
Dynamic text properties
After dynamic text has been added to the page layout, you can change dynamic text properties by double-clicking the dynamic text.
The Dynamic Text Properties dialog box displays three tabs for changing properties:
- Area
- Size and Position
- Dynamic Text
These tabs allow you to change the symbol and the properties of the existing piece of dynamic text, as well as add additional text or add another piece of dynamic text to the existing one. This allows you to insert dynamic text into notes or paragraphs.
Formatting options allow you to center, right justify, or left justify the text paragraph. Other formatting options include bold, underline, italic, subscript, superscript, and so forth.
You can change the placement properties by defining element rules. See Page element rules for more details.
Dynamic text and VBScript
Dynamic text can be inserted in the page layout of a map or chart to display any of the following:
- The computer name
- Data frame properties
- The current date and time
- Feature class properties
- Feature layer properties
- Map sheet name
- Table field values
- The current user name
- Coordinate values
Visual Basic Scripting Edition (VBScript) is used to create programmatic expressions that can be applied to attributes of features in your map. Expressions can be used to further refine the way text strings appear on your map.
When VBScript expressions are defined for dynamic text, you can choose a single field value or an array of values for the selected field. In some instances, the expression is applied based on a SQL statement you have defined to indicate what field values you want to have available for the VBScript. This includes feature class and feature layer attributes as well as table fields. Other types of dynamic text, such as the user name, date and time, and computer name, can have an expression that is based on predefined fields.
Learn more about label expressions
The Expression Builder presents you with the skeleton of a function named Generate that is populated with parameters that are derived from the dynamic text you are using. This function returns a single value. The sample below reads each state name in the array parameter and appends it to a string along with a carriage return.
Function Generate([ObjectID], [ObjectID_arr], [STATE_NAME], [STATE_NAME_arr]...) Dim retstr ' define our return string for i = 0 to Ubound([STATE_NAME_arr]) ' loop through each element retstr = retstr & [STATE_NAME_arr](i) ' append value to our string retstr = retstr & vbCrLf ' append a return character Next Generate = retstr ' return our final string End Function
The output of the expression would look like this:
Colorado Utah Arizona New Mexico