DDEInitiate Method

Applies To

Application Object.

Description

Opens a DDE channel to an application.

Syntax

object.DDEInitiate(app, topic)

object

Optional. The Application object.

app

Required. A string containing the application name.

topic

Required. A string that describes something in the application to which you are opening a channel, usually a document of that application.

Remarks

If successful, the DDEInitiate method returns the number of the open channel. All subsequent DDE functions use this number to specify the channel.

Example

This example opens a channel to Word 6.0 for Windows, opens the Word document FORMLETR.DOC, and then sends the FilePrint command to WordBasic.


channelNumber = Application.DDEInitiate( _
    app:="WinWord", _
    topic:="C:\WINWORD\FORMLETR.DOC")
Application.DDEExecute channelNumber, "[FILEPRINT]"
Application.DDETerminate channelNumber

This example opens a channel to Word 6.0 for the Macintosh, opens the Word document Form Letter, and then sends the FilePrint command to WordBasic. On the Macintosh, you must use the Shell function to start Word, because the DDEInitiate method does not automatically start Word as it does in Windows. Also, because the Shell function is asynchronous, the macro may call the DDEInitiate method before Word has started. This example demonstrates how you can program around this by putting the DDEInitiate method call in a loop, testing channelNumber until it is no longer an error.


Shell "HD:Form Letter", 6
Do
    channelNumber = Application.DDEInitiate( _
        app:="MSWord", _
        topic:="HD:Form Letter")
Loop Until TypeName(channelNumber) <> "Error"
Application.DDEExecute channelNumber, "[FILEPRINT]"
Application.DDETerminate channelNumber