Sends a command or series of commands to an application through the specified dynamic data exchange (DDE) channel.
Security Dynamic data exchange (DDE) is an older technology that is not secure. If possible, use a more secure alternative to DDE, such as object linking and embedding (OLE).
expression.DDEExecute(Channel, Command)
expression Optional. An expression that returns an Application object.
Channel Required Long. The channel number returned by the DDEInitiate method.
Command Required String. A command or series of commands recognized by the receiving application (the DDE server). If the receiving application cannot perform the specified command, an error occurs.
Example
This example creates a new worksheet in Microsoft Excel. The XLM macro instruction to create a new worksheet is New(1)
.
Dim lngChannel As Long
lngChannel = DDEInitiate(App:="Excel", Topic:="System")
DDEExecute Channel:=lngChannel, Command:="[New(1)]"
DDETerminate Channel:=lngChannel
This example runs the Microsoft Excel macro named "Macro1" in Personal.xls.
Dim lngChannel As Long
lngChannel = DDEInitiate(App:="Excel", Topic:="System")
DDEExecute Channel:=lngChannel, Command:="[Run(" & Chr(34) & _
"Personal.xls!Macro1" & Chr(34) & ")]"
DDETerminate Channel:=lngChannel