date stamping mxd in arcgis 10

Discussion created by frankv3 on Oct 6, 2010
Latest reply on Dec 10, 2010 by msteinbrenner
In our 9.3.1 MXDs we use a VBA function stored in the ThisDocument of the MXD to date stamp the maps as they are opened. Does anyone know if this will work in ArcGIS10 or if not what we can use to perform the same type of function?
This is what we currently use:

Option Explicit
Private WithEvents m_pActiveViewEvents As Map

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

Private Function MxDocument_BeforeCloseDocument() As Boolean
End Function

Private Function MxDocument_OpenDocument() As Boolean
End Function

Public Sub SetEvents()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Set m_pActiveViewEvents = pMxDoc.PageLayout
End Sub

Public Sub UnSetEvents()
Set m_pActiveViewEvents = Nothing
End Sub

Private Sub m_pActiveViewEvents_ViewRefreshed(ByVal pView As IActiveView, _
ByVal phase As esriViewDrawPhase, _
ByVal data As Variant, _
ByVal Envelope As IEnvelope)

Dim pGC As IGraphicsContainer
Set pGC = pView
Dim pElement As IElement
Set pElement = pGC.Next
Do While Not pElement Is Nothing
If TypeOf pElement Is ITextElement Then
Dim pTextElement As ITextElement
Set pTextElement = pElement
If UCase(Mid(pTextElement.Text, 1, 5)) = "DATE:" Then
pTextElement.Text = "DATE: " & Date
End If
End If
Set pElement = pGC.Next

End Sub

Function UserName() As String
Dim UN As String * 260
GetUserName UN, Len(UN)
UserName = UN
End Function