XL: Sample Code Demonstrating DDEPoke and POKE()

ID: Q139881


The information in this article applies to:
  • Microsoft Excel 97 for Windows
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Excel for Windows NT, version 5.0
  • Microsoft Excel for Windows, versions 3.0, 4.0, 5.0
  • Microsoft Excel for the Macintosh, versions 3.0, 4.0, 5.0


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:

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


Last Reviewed: November 9, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.