Ann, Jeff, please could put code in Visual Basic Net, it happens that I can not do the equivalent = (.. I'm still very puppy programming on these issues.
Greetings!
You have to, of course, declair ArcMap. Public Sub PerformTest()
Const myParaTextID As String = "MyDisclaimerTextID"
Dim paraText As String = "Sample disclaimer paragraph text"
Dim graphicsContainer As ESRI.ArcGIS.Carto.IGraphicsContainer = TryCast(ArcMap.Document.PageLayout, ESRI.ArcGIS.Carto.IGraphicsContainer)
Dim element As ESRI.ArcGIS.Carto.IElement
Dim elementProperties As ESRI.ArcGIS.Carto.IElementProperties
' Check if the disclaimer text element already exists in layout
graphicsContainer.Reset()
element = graphicsContainer.Next()
While element IsNot Nothing
If TypeOf element Is ESRI.ArcGIS.Carto.IParagraphTextElement Then
elementProperties = TryCast(element, ESRI.ArcGIS.Carto.IElementProperties)
If elementProperties.Name = myParaTextID Then
MessageBox.Show("The Disclaimer Text, which autoupdates " & "the time and date, is already placed in the map.")
Return
End If
End If
element = graphicsContainer.Next()
End While
' No disclaimer found, so make one
Dim paraTextElement As ESRI.ArcGIS.Carto.IParagraphTextElement = New ESRI.ArcGIS.Carto.ParagraphTextElementClass()
Dim textElement As ESRI.ArcGIS.Carto.ITextElement = TryCast(paraTextElement, ESRI.ArcGIS.Carto.ITextElement)
elementProperties = TryCast(paraTextElement, ESRI.ArcGIS.Carto.IElementProperties)
element = TryCast(paraTextElement, ESRI.ArcGIS.Carto.IElement)
' Set this so it can be found if this method called again
elementProperties.Name = myParaTextID
' Set the actual text to display
textElement.Text = paraText
' Set the size and location of the text box
Dim envelope As ESRI.ArcGIS.Geometry.IEnvelope = New esri.ArcGIS.Geometry.EnvelopeClass()
envelope.PutCoords(0, 0, 3, 1)
element.Geometry = envelope
' Add the text box to the layout
graphicsContainer.AddElement(element, 0)
ArcMap.Document.ActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
End Sub