Microsoft KB Archive/139881

= Sample Code Demonstrating DDEPoke and POKE =

Article ID: 139881

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition
 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0 Standard Edition

-



This article was previously published under Q139881



SUMMARY
This article contains two examples of how you can use Microsoft Excel to "poke" data to another application during a DDE conversation.

The commands in both examples, DDEPoke (Visual Basic for Applications) and POKE (Microsoft Excel 4.0 Macro language), accept three arguments: Channel Number, Item, and Data.

Note that the Data argument can only refer to text or numbers that are represented by a range object. You cannot directly use a string or numeric value for the Data argument or the command will fail.



Visual Basic for Applications
To successfully use DDEPoke, place the text ("Hello World!" in this example) in a cell and reference the range object with DDEPoke. For example, if Sheet1!A1 contains the text "Hello World!", use the following command: DDEPoke chan, "MyBookmark", Sheets("Sheet1").Range("A1") Note that the following command will fail because the Data argument is a string: DDEPoke chan, "MyBookmark", "Hello World!"

Microsoft Excel 4.0 Macro Language
To successfully use POKE, place the text (in this example "Hello World!") in a cell and reference the cell with POKE. For example, if Sheet1!A1 contains the text "Hello World!", use the following command: =POKE(chan, "MyBookmark", Sheet1!A1) Note, however, that the following command will fail because the Data argument is a string: =POKE(chan, "MyBookmark", "Hello World!")

