Microsoft KB Archive/97164

{| = PRB: DDERequest from MS Excel Returns Extra Characters =
 * width="100%"|

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 &quot;1&quot; (without the quotation marks) and

press ENTER. 3. Open the Debug window in FoxPro and type &quot;x&quot; (without the quotation  marks). 4. In the Command window, issue the following commands: chan = DDEInitiate(&quot;Excel&quot;,&quot;Sheet1&quot;) x = DDERequest(chan,&quot;R1C1&quot;) =DDETerminate(chan) In the Debug window, the variable x appears as a character string containing &quot;1&quot; 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
 * }