HOW TO
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.
Object Property Setting
Text Box Name txtDDE
Command Button Caption Send Request
Name cmdRequest
Combo Box Name cboDocType
Code:
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
FireUp:
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
Resume
Else
MsgBox "Unknown error."
Stop
End If
End Sub
Code:
Sub Form_Load ()
cboDocType.text = ""
cboDocType.AddItem "View"
cboDocType.AddItem "Layout"
cboDocType.AddItem "SEd"
Startup 'calls startup procedure
End Sub
Code:
Sub Form_Unload (Cancel As Integer)
txtDDE.LinkMode = NONE 'Close DDE conversation
End Sub
Code:
Sub cboDocType_Click()
Dim cmd
cmd = "theDoc = av.GetProject.AddDoc(" & cboDocType & ".make) av.GetProject.GetSelectedDocs.Get(0).GetWin.Open "
txtDDE.LinkExecute cmd
End Sub
Code:
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"
txtDDE.LinkRequest
End Sub
Article ID:000003996
Get help from ArcGIS experts
Download the Esri Support App