Launch ArcView from Visual Basic

Last Published: April 25, 2020


In this example, the Visual Basic application sends Avenue requests to ArcView that create new documents, such as views and layouts. Additionally, the application can query ArcView to obtain the current active document. The Visual Basic application is the destination application, while ArcView is the source application.


Visual Basic and ArcView must be installed to perform the following steps.

  1. Start Visual Basic and Form1 will be created by default.
  2. Create the following controls with the following properties on Form1, then resize the form so that it neatly contains the controls.

    Object		Property	Setting
    Text Box Name txtDDE
    Command Button Caption Send Request
    Name cmdRequest
    Combo Box Name cboDocType

  3. Add the following code to the general declaration section of Form1:

    Const NONE = 0, MANUAL = 2

    Sub Startup() 'Note: Visual Basic will create this subroutine
    'in a separate window from the general declarations
    Dim t
    Const DDE_NO_APP = 282 'error if no response
    'see Trappable errors
    'this will start ArcView if it isn't running
    On Error GoTo FireUp
    txtDDE.LinkMode = NONE 'Clear DDE Link
    txtDDE.LinkTopic = "ArcView|System" 'Set up conversation
    txtDDE.LinkMode = MANUAL 'Establish a manual link
    Exit Sub


    If Err = DDE_NO_APP Then
    ChDir "C:\esri\av_gis30\arcview\bin32" ' wherever ArcView was installed
    ' the ChDir is required
    t = Shell("arcview", 1)
    t = DoEvents() 'process Windows events
    MsgBox "Unknown error."
    End If
    End Sub

  4. Add the following code to the Form_Load event procedure:

    Sub Form_Load ()
    cboDocType.text = ""
    cboDocType.AddItem "View"
    cboDocType.AddItem "Layout"
    cboDocType.AddItem "SEd"
    Startup 'calls startup procedure
    End Sub

  5. Add the following code to the Form_Unload event procedure:

    Sub Form_Unload (Cancel As Integer)
    txtDDE.LinkMode = NONE 'Close DDE conversation
    End Sub

  6. Add the following code to the cboDocType_Click event procedure:

    Sub cboDocType_Click()
    Dim cmd
    cmd = "theDoc = av.GetProject.AddDoc(" & cboDocType & ".make) av.GetProject.GetSelectedDocs.Get(0).GetWin.Open "
    txtDDE.LinkExecute cmd
    End Sub

  7. Add the following code to the cmdRequest_Click event procedure:

    Sub cmdRequest_Click ()
    'When selected this button will request an update of
    'information from the source application to the
    'destination application
    'LinkItem can be any Avenue script that returns a value
    txtDDE.LinkItem = "av.GetActiveDoc.GetName"
    End Sub

  8. Save your Visual Basic project and make an .EXE file.

    You can now run the Visual Basic application. If ArcView is not running, the application will start it. Choosing a document name from the dropdown combo box creates a document in ArcView. To request the current active document click the Send Request button. The name of the document displays in the text box.

    In this example, all DDE communication passes through the text box. In Visual Basic, any text box, picture box, or label can be the destination in a conversation, while any form can be a source.

Article ID:000003996

  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic