HOW TO
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.
Code: '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 theLayout.SetCloseScript("") else theLayout.SetCloseScript("Layout.Close") End '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) TText.SetObjectTag("date") theLayout.GetGraphics.Add(TText) theLayout.Invalidate return nil
Note: For more information on creating a tool see the ArcView help topic "Customizing Tools".
Code: '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) End End theDoc.GetWin.Close
Note: This script can be added (with modifications) to the Project.Close, Project.CloseDoc, and Project.CloseAll scripts if desired.
Get help from ArcGIS experts
Download the Esri Support App