How To: Add a time and date stamp to a layout


The following scripts can be used to add a time and date stamp to a layout and update the text box when the layout and/or project is closed.


  • Create the Layout.Date script
    'Script Name: layout_date.ave
    'This script will add a text box with the time and date.
    'The text attributes are taken from the Symbol Window.
    'Get the location for the text box
    theLayout = av.GetActiveDoc
    theDisplay = theLayout.getDisplay
    TPoint = theDisplay.ReturnUserPoint
    'Set the close script to the custom Layout.Close script
    theScript = av.FindScript("Layout.Close")
    If (theScript = Nil) then
    'Get the time (military format) and date
    now = Date.Now
    nowString = now.SetFormat("hhh:m, MM/dd/yyyy").AsString
    'Create a text box and add the time and date
    TText = GraphicText.Make("Last updated:" ++ nowString,TPoint)
    return nil

    and add a tool in the layout GUI using Layout.Date as the apply script
    1. Copy and paste layout_date.ave into a new script window and compile it.

    2. From the Script pull down menu select Properties.

    3. Rename the script to Layout.Date and click Ok.

    4. Make a Layout active and double click on an empty area of the button/tool bar.

    5. In the Customize Dialog change the Type to Layouts (if necessary) and the Category to Tools.

    6. Insert the new tool in the desired location on the tool bar.

    7. With the new tool active, double click on the empty box to the right of Apply.

    8. Navigate to Layout_Date and click Ok.

    9. Change any other desired properties of the tool and close the Customize dialog.
    For more information on creating a tool see the ArcView help topic "Customizing Tools".
    • The following steps will update the time and date stamp each time the layout is closed.

      1. Add the script layout_close.ave
      'Script name: layout_close.ave
      theDoc = av.GetActiveDoc
      theText = theDoc.GetGraphics
      'Update the date and time stamp for each text box created with
      'the new tool
      For each t in theText
      	If (t.GetObjectTag = "date") then
      		now = Date.Now
      		nowString = now.SetFormat("hh:m, MM/dd/yyyy").AsString
      		t.SetText("Last updated:" ++ nowString)

      to a new script window and compile it.

      2. Rename the script to Layout.Date

      3. From the Edit pull down menu select Embed Script. The script will NOT be recognized unless it is embeded.
      This script can be added (with modifications) to the Project.Close, Project.CloseDoc, and Project.CloseAll scripts if desired.