DDEInitiate (function)

Syntax DDEInitiate (application$, topic$)
Description Initializes a DDE link to another application and returns a unique number subsequently used to refer to the open DDE channel.
Comments The DDEInitiate statement takes the following parameters:
Parameter Description
Application$ String containing the name of the application (the server) with which a DDE conversation will be established.
Topic$ String containing the name of the topic for the conversation. The possible values for this parameter are described in the documentation for the server application.
This function returns 0 if the link cannot be established. This will occur under any of the following circumstances:
  • The specified application is not running.
  • The topic was invalid for that application.
  • Memory or system resources are insufficient to establish the DDE link.
Example This example sets and retrieves a cell in an Excel spreadsheet.
Sub Main()
  Dim cmd,q,ch%
  q = Chr(34) ' Define quotation marks.
 
  id = Shell("c:\excel5\excel.exe",3) 'Start Excel.
  ch% = DDEInitiate("Excel","Sheet1")
 
  On Error Resume Next
  cmd = "[ACTIVATE(" & q &"SHEET1" & q & ")]" 'Activate worksheet.
  DDEExecute ch%,cmd
 
  DDEPoke ch%,"R1C1","$1000.00"   'Send value to cell.
  'Retrieve value and display.
  MsgBox "The value of Row 1, Cell 1 is: " & DDERequest(ch%,"R1C1")
 
  DDETerminate ch%
  Msgbox "Finished..."
End Sub
See Also DDEExecute (statement); DDEPoke (statement); DDERequest, DDERequest$ (functions); DDESend (function); DDETerminate (statement); DDETerminateAll (statement); DDETimeout (statement).