My mxd has a dataframe which contains a MS Word-Object ("Insert" – "Object").
The Object was added to data view.
I want to access the MXD dataframe in PyScripter using
arcpy.mapping.ListDataFrames(mxd)[0]
However, I get the following error:
AttributeError: 'NoneType' object has no attribute 'dataFrames'
I'd also like to import the MXD to ArcGIS Pro but it doesn't work, I get an error.
When I delete the Word-Object all these errors do not occur.
(Note: When I use the Python window in ArcMap, the AttributeError does not occur. However, I would like to make it work in PyScripter)
I thought about deleting the Word-Object with ArcPy, is that possible? I have hundreds of MXDs with this Word-Object, so I need to automate this.
I already tried using ListLayoutElements but nothing is returned because the object was added in data view.
Best Answer
I don't think arcpy exposes any methods that allow you to delete OLE objects inserted into a data frame. You can automate this using ArcObjects.
So in screen shot below I have a polyline layer, graphic and an OLE word document in a map view (so NOT layout).
The following VBA code will find any OLE frame and delete it:
You can run this directly inside the VBA editor in ArcMap, or you now have the basic template of code to convert this into VB.Net and run it as outside ArcMap, your choice.
After running this code we see only the Word OLE element has been removed.