How To: Open and close projects with Avenue


This document shows how you can close a current project and open a predefined project by clicking on a Menu, Button, or Tool.


  1. Copy the OpenProject and OpenProject2 scripts into new separate script windows of a new blank project.
    'Script Name: OpenProject
    'Modified from System Script Project.Open
    theProject = av.GetProject
    if (nil <> theProject) then
      if (theProject.IsModified) then
        if (av.Run("Project.CheckForEdits",nil).Not) then
          return nil
        res = MsgBox.SaveChanges("Do you want to save changes to " 
                                 + theProject.GetName + "?", "ArcView", true)
        if (nil = res) then return nil end
        if (res) then
          av.Run("Project.Save", nil)
          if (theProject.IsModified)then return nil end
    theFName = SELF.GetTag.AsFileName
    if (nil <> theFName) then
      if (nil <> theProject) then
      theProject = nil
      av.DelayedRun("OpenProject2", theFName, 0)
    'Script Name: OpenProject2
    'Modified from System Script Project.OpenPart2
    ' self is the name of the project to open
    theProj = av.GetProject
    if (theProj <> nil) then
      guiModified = av.Run("Project.UpdateApr",nil)
  2. Rename the script window to match the name of the script.
    A. Select Properties from the Script menu.
    B. Type in a new name in the Name field.
    C. Click OK.
  3. Attach the OpenProject script to a control on a GUI, for example a button on the View GUI.
    A. Compile the script.
    B. Switch to the Project window.
    C. Select Customize from the Project menu.
    D. On the Customize dialog box, click the Type dropdown arrow and click View.
    E. Select Buttons under Category.
    F. Click the New button.
    G. Double-click the Click property in the Customize dialog box.
    H. Type the name of the script in the Script Manager and click Select.
    I. Close the Customize dialog box.

    For more information, see "Customize dialog box" in ArcView Help.
  4. Set the tag of the new control to the full path and filename of the project to open.
    A. Switch to the Project window
    B. Select Customize from the Project menu
    C. On the Customize dialog switch the Type dropdown to the GUI where the control is located
    D. Switch the Category dropdown to the type of control you are setting
    E. Select the control
    F. Double-click the Tag property at the bottom of the Customize dialog
    G. Enter the desired text and click OK
    H. Close the Customize dialog box
  5. Make the project the default project.
    A. Switch to the Project window
    B. Select Customize from the Project Menu
    C. Click Make Default on the Customize dialog box
    D. Close the Customize dialog box
    The Make Default button is not available if any extension are turned on. To activate this button turn off all extensions.
    Make sure both scripts are compiled.
  6. Restart ArcView. The new control will be added automatically.