XL: Sample Code Demonstrating DDEPoke and POKE()

ID: Q139881

The information in this article applies to:

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.

MORE INFORMATION

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!")

REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 10, Section "Using DDE," pages 209-213

Additional query words: 3.00 4.00 5.00 7.00

Keywords          : kbprg PgmHowto 
Version           : WINDOWS:3.0,4.0,5.0,7.0; MACINTOSH:3.0,4.0
Platform          : MACINTOSH WINDOWS
Issue type        : kbhowto

Last Reviewed: December 2, 1997