PRB: DDERequest() from MS Excel Returns Extra Characters

Last reviewed: June 26, 1995
Article ID: Q97164
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

The DDERequest() function can be used to return data from a cell in a Microsoft Excel file. (See below for an example.)

The contents of the cell are returned as a text string that is terminated by the ASCII characters 10 and 13 (carriage return and linefeed.) To obtain the desired result, you may need to use FoxPro commands to manipulate these strings.

MORE INFORMATION

  1. Start Microsoft Excel. By default, it starts with Sheet1.

  2. In cell A1 of Sheet1, type "1" (without the quotation marks) and press ENTER.

  3. Open the Debug window in FoxPro and type "x" (without the quotation marks).

  4. In the Command window, issue the following commands:

          chan = DDEInitiate("Excel","Sheet1")
          x = DDERequest(chan,"R1C1")
          =DDETerminate(chan)
    

In the Debug window, the variable x appears as a character string containing "1" followed by two symbols. These symbols are ASCII characters 13 and 10, representing a carriage return and linefeed, respectively.

To remove these extra characters, use the following command:

  x=left(x,len(x)-2)

The variable x now contains the contents of the Microsoft Excel cell without the extra characters.


Additional reference words: FoxWin 2.50 2.50a DDE
KBCategory: kbprg kbprb
KBSubcategory: FxinteropDde


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: June 26, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.