XL: Sample Code Demonstrating DDEPoke and POKE()

Last reviewed: December 1, 1997
Article 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: 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


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 1, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.