Script or code to plot file path & name, time, and date

Discussion created by pelampe on Oct 9, 2010
Latest reply on May 6, 2013 by CorrieFochler

I am running ArcGIS (ArcView license) 9.3.1 right now, but will eventually migrate over to 10 over the next few months.

I would like to add some form of automation to the MXD so that every time I print it will print out the map the file path/name, time, and date.

I found some code from the old forum site below.

Code for the above link is below:
Public Sub AddFilePath()

Dim pApplication As Application
Dim pDocument As IDocument
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pLayout As IPageLayout
Dim pActiveView As IActiveView
Dim pGraphicsCont As IGraphicsContainer
Dim pElement As IElement
Dim pElementProp As IElementProperties
Dim pTextElement As ITextElement

Set pApplication = Application
Set pDocument = pApplication.Document
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.Maps.Item(0) 'must be the first Data Frame in the map
Set pLayout = pMxDoc.PageLayout
Set pActiveView = pMxDoc.ActiveView

'Scroll through all elements on the layout
Set pGraphicsCont = pActiveView.GraphicsContainer
Set pElement = pGraphicsCont.Next
Do Until pElement Is Nothing
  'Check the element's name - we are looking for one called "FileName"
  Set pElementProp = pElement
  If pElementProp.Name = "FileName" Then
    'Double-check that this is a text element
    If TypeOf pElement Is ITextElement Then
      'Update the text to the file path of the project
      Set pTextElement = pElement
      pTextElement.Text = pDocument.VBProject.FileName & " Last updated " & Now
    End If
  End If
  'Move on to the next graphic element
  Set pElement = pGraphicsCont.Next

'Refresh the display
pActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing

End Sub


Below I am giving you my questions AND what I changes I'd like to integrate into the above code to make it a little more applicable for my situation.

Here are my questions:

  1. I was wondering if anyone has any input on improving (if even necessary) the code shown above or has any other suggestions or ideas to accomplish this task.

  2. Will the above code work with 10?

Here are my desired modifications:

  1. I would like to have the stamp look this way:

  2. Map Plotted: 10-08-10 15:50, Map Edited: 10-08-10 15:49, File: C:\Maps\Client\Map.mxd
  3. Where: The Map Plotted date is the current date and time (in 24hr format) entity

  4. Where: The Map Edited date is the last modified date and time (in 24hr format) entity

  5. Where: The File is the file path and file name entity

TIA for your replies.