shrug-l: System Variable in Annotation

Ross,Gregory K gkross at
Tue Feb 28 12:10:57 EST 2006

Try adding the following VBA code to your map. You will have to modify
it to suit your needs. You can email me if you have any questions.
Gregory Ross
Senior Laboratory Technician
University of Florida / IFAS
Florida Medical Entomology Laboratory
200 9th Street SE
Vero Beach, FL  32962
772-778-7200 ext 152 <> <>

Dim pMxDoc As IMxDocument
Dim pGraphicsContainer As IGraphicsContainer
Dim pPageLayout As IPageLayout
Dim pEnumElement As IEnumElement
Dim pTextElement As ITextElement
Dim pElement As IElement

Private Function MxDocument_OpenDocument() As Boolean
Set pMxDoc = ThisDocument
Set pPageLayout = pMxDoc.PageLayout
Set pGraphicsContainer = pPageLayout
Dim pPoint As IPoint
Set pPoint = New Point
'enter the x and y values of your text element here
pPoint.x = 2
pPoint.y = 2
Set pEnumElement = pGraphicsContainer.LocateElements(pPoint, 0.5)
Set pElement = pEnumElement.Next
If TypeOf pElement Is ITextElement Then
    pGraphicsContainer.DeleteElement pElement
    Call Project.AddDate.AddText
    Exit Function
End If
Dim m_pMxDoc As IMxDocument
Dim m_pPageLayout As PageLayout
Dim m_pGContainer As IGraphicsContainer
Public Sub AddElement(AnElement As IElement, PagePosition As IGeometry)
Set m_pMxDoc = ThisDocument
Set m_pPageLayout = m_pMxDoc.PageLayout
AnElement.Geometry = PagePosition
Set m_pGContainer = m_pPageLayout
m_pGContainer.AddElement AnElement, 0
End Sub
Public Sub AddText()
Dim pTextElement As ITextElement
Set pTextElement = New TextElement
 ''retrieve the document title
 Dim pDocumentTitle As String
 Dim pDocument As IDocument
 Set pDocument = Application.Document
 pDocumentTitle = pDocument.Title
pTextElement.Text = "The date / time is :  " & Now & vbCrLf & _
                    "The document name is :  " & pDocumentTitle
''create a point for the location of the text
Dim pPoint As IPoint
Set pPoint = New Point
'enter the x and y values of your text element here
pPoint.x = 2
pPoint.y = 2
AddElement pTextElement, pPoint
End Sub


	From: Sykes, John [mailto:John.Sykes at] 
	Sent: Tuesday, February 28, 2006 10:04 AM
	To: shrug-L at
	Subject: shrug-l: System Variable in Annotation

	Does anyone here know how you can include a system variable,
such as the file name or today's date, last modified date, etc. in a
layout annotation (I keep forgetting to update the "Revised:" dates on
my ?/&@?$!**@%*^ printed maps).  I've pretty well mastered modifying
labels using Visual Basic scripts, but the same techniques don't appear
to work on text annotations.  I tried using VB scripts, but all the
script delineators I tried printed out literally (e.g., single quotes,
double quotes, left & right brackets, etc.).

	-- John 

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the SHRUG-L mailing list