How to Set a Map Page Text Element Visibilty to False

11-30-2016 08:41 AM
Occasional Contributor

I am using data driven pages in which I want a text element only shown in the identified page.

However, when I change pages the text element is still visible.

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")

# The text element is a textbox
elm = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "closeup")[0]
currentpage = mxd.dataDrivenPages.currentPageID

# (PAGE NAME 220 Also Known As (PAGE NUMBER 193) Must refer to PAGE NUMBER when scripting.
if currentpage == 193:
    elm.visible = True
elif currentpage != 193:
    elm.visible = False

0 Kudos
0 Replies