Applies To
Application Object.
Description
Sends data to an application.
Syntax
object.DDEPoke(channel, item, data)
object
Optional. The Application object.
channel
Required. The channel number returned by the DDEInitiate method.
item
Required. The item to which the data is to be sent.
data
Required. The data to send to the application.
Remarks
An error occurs if the method call is not successful.
Example
This example opens a channel to Word 6.0 for Windows, opens the Word document SALES.DOC, and then inserts the contents of cell A1 (on Sheet1) at the beginning of the document.
channelNumber = Application.DDEInitiate( _ app:="WinWord", _ topic:="C:\WINWORD\SALES.DOC") Set rangeToPoke = Worksheets("Sheet1").Range("A1") Application.DDEPoke channelNumber, "\StartOfDoc", rangeToPoke Application.DDETerminate channelNumber
This example opens a channel to Word 6.0 for the Macintosh, opens the Word document Sales Report, and then inserts the contents of cell A1 (on Sheet1) at the beginning of the document. 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:Sales Report", 6 Do channelNumber = Application.DDEInitiate( _ app:="WinWord", _ topic:="HD:Sales Report") Loop Until TypeName(channelNumber) <> "Error" Set rangeToPoke = Worksheets("Sheet1").Range("A1") Application.DDEPoke channelNumber, "\StartOfDoc", rangeToPoke Application.DDETerminate channelNumber