I created a Python Toolbox which calculates statisitics about some layers and print a pdf layout.

The layout and table frame elements already exist.

enter image description here

I try to access the table frame elements from my Python script to do some modifcations on fields to show, field order and table frame position.

aprx = arcpy.mp.ArcGISProject("CURRENT")  # my project
m = aprx.listMaps("Map2")[0]  # my map
lyr = m.listLayers("Clip_Reco_Dissolve1")[0]  # source layer for the table frame
lyt = aprx.listLayouts('Tabloid_Paysage_Unique_test')[0]  # my layout
fieldNames = ["Categorie", "COUNT_Categorie"]  # fields to display

elm = lyt.listElements("GRAPHIC_ELEMENT", "Categorie ressource")  # name of the table frame in the layout content

The only way I found in Esri documentation is using last row, but it is not working. I tried again after converting this element to graphic, but it doesn't work either, and anyway I need to manipulate it as table frame to manage fields, before changing its position.

elm = lyt.listElements("GRAPHIC_ELEMENT", "Categorie ressource")
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1840, in listElements
    return convertArcObjectToPythonObject(self._arc_object.listElements(*gp_fixargs((element_type, wildcard), True)))

1 Answer 1


I believe you are going to have to use the CIM access to reach into the table frame structure. Look at the TableFrame examples in the ArcGIS Pro Python CIM Samples.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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