#1 Thu 17 June 2004 18:18
- Laurent Frilleux
- Invité
[ArcGIS 8.3] Date dans une Mise En Page
Bonjour
La question a deja ete pose il ya longtemps mais je n'ai pas trouve la reponse dans les archives.
Peut on dans arcgis 8.3 inserer dans une MEP une fonction pour mettre automatiquement a jour une date dans un document ?
Merci
Laurent FRILLEUX
Cartographie et formation SIG STRATEGIS S.A.
www.strategis.fr
#2 Mon 21 June 2004 20:40
- Olivier GUYOT-DE-LA-POMMERAYE
- Invité
Re: [ArcGIS 8.3] Date dans une Mise En Page
Bonjour,
L'idee serait de placer la date toujours au meme endroit dans vos mises en pages, et de mettre le mot "Date" en plus de la date elle-meme.
Ensuite il suffit de placer le code ci dessous directement sur l'evenement "MxDocument_OpenDocument" du module de classe "ThisDocument", afin que celui-ci se declenche lors de l'ouverture de vos documents.
Code:
Option Explicit
Dim oMxDoc As IMxDocument
Dim oMap As IMap
Dim oActiveView As IActiveView
Dim oPoint As IPoint
Private Function MxDocument_OpenDocument() As Boolean
Call Update_DateFromMEP
End Function
Private Sub Update_DateFromMEP()
Dim NoDateExist As Boolean
Dim oGraphicsContainer As IGraphicsContainer
NoDateExist = False
Set oMxDoc = Application.Document
If Not oMxDoc.ActiveView Is oMxDoc.PageLayout Then Exit Sub
Set oActiveView = oMxDoc.PageLayout
Set oGraphicsContainer = oMxDoc.PageLayout
Set oPoint = New Point
oPoint.PutCoords 3, 28
Dim oIEnumElement As IEnumElement
Set oIEnumElement = oGraphicsContainer.LocateElements(oPoint, 0)
Dim oITextElement As ITextElement
Dim oIElement As IElement
Set oIElement = oIEnumElement.Next
Do While Not oIElement Is Nothing
If TypeOf oIElement Is ITextElement Then
Set oITextElement = oIElement
If InStr(1, oITextElement.Text, "Date") Then
oITextElement.Text = "Date: " & Date
oGraphicsContainer.UpdateElement oIElement
NoDateExist = True
Exit Do
End If
End If
Set oIElement = oIEnumElement.Next
Loop
If NoDateExist = False Then
Call Add_DateToMEP
End If
oMxDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
Private Sub Add_DateToMEP()
Dim oGraphicsContainer As IGraphicsContainer
Dim oITextElement As ITextElement
Dim oIElement As IElement
Set oMxDoc = Application.Document
If Not oMxDoc.ActiveView Is oMxDoc.PageLayout Then Exit Sub
Set oActiveView = oMxDoc.PageLayout
Set oGraphicsContainer = oMxDoc.PageLayout
Set oITextElement = New TextElement
Set oIElement = oITextElement
oITextElement.Text = "Date: " & Date
Set oPoint = New Point
oPoint.PutCoords 3, 28
oIElement.Geometry = oPoint
oGraphicsContainer.AddElement oITextElement, 0
oMxDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End SubReste pour vous a determiner l'endroit ou vous souhaitez voir apparaitre la date.
Cordialement,
Olivier Guyot de La Pommeraye


