DDEExecute (statement)

Syntax

DDEExecute channel, command$

Description

Executes a command in another application.

Comments

The DDEExecute statement takes the following parameters:

 

Parameter

Description

 

Channel

Integer containing the DDE channel number returned from DDEInitiate. An error will result if channel is invalid.

 

Command$

String containing the command to be executed. The format of command$ depends on the receiving application.

 

If the receiving application does not execute the instructions, a runtime error is generated.

Example

This example sets and retrieves a cell in an Excel spreadsheet. The command strings being created contain Microsoft Excel macro commands and may be concatenated and sent as one string to speed things up.

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

DDEInitiate (function); DDEPoke (statement); DDERequest, DDERequest$ (functions); DDESend (function); DDETerminate (statement); DDETerminateAll (statement); DDETimeout (statement).

More information

D