AnsweredAssumed Answered

Select TextElement and delete it from layout

Question asked by Alberto on Mar 8, 2012
Latest reply on Mar 8, 2012 by Alberto
Hi folks,
I've to regenerate a single layout with data from each point feature. So, I wrote a routine to clean the layout, searching for text element, selecting it and deleting it.
Well, the routine works just for some element and not for others.... Why?

Private Sub CleanLayout()          Dim graphC As IGraphicsContainer = mxDocument.PageLayout         Dim graphCSel As IGraphicsContainerSelect = graphC         graphCSel.UnselectAllElements()         graphC.Reset()         Dim elem As IElement = graphC.Next         While elem IsNot Nothing             If TypeOf elem Is ESRI.ArcGIS.Carto.ITextElement Then                 Dim elemProps As IElementProperties = DirectCast(elem, IElementProperties)                 If String.Compare(elemProps.Name, "ELEM_VAR", True) = 0 Then                     graphCSel = graphC                     graphCSel.SelectElement(elem)                     graphC.DeleteElement(elem)                 End If             End If             elem = graphC.Next         End While          mxDocument.ActiveView.Refresh()         graphC = Nothing         graphCSel = Nothing  End Sub


The result is that there is still some text element named "ELEM_VAR" on the layout....

Thanks in advance for any help.
Software: ArcGIS 10 SP1 + VS2010

Outcomes