Character Field Transferred to Microsoft Excel as Numeric

ID: Q111872

The information in this article applies to:

SYMPTOMS

A FoxPro character type field that contains numbers is converted to a numeric field in Microsoft Excel when the FoxPro dynamic data exchange (DDE) functions are used.

RESOLUTION

To avoid this situation, do one of the following:

MORE INFORMATION

Steps to Reproduce Problem

1. Open Microsoft Excel with Sheet1 as the active worksheet.

2. Open FoxPro for Windows and issue the following commands from the

   Command window:

      CREATE TABLE xddetst.dbf (fld1 C(8))
      APPEND BLANK
      REPLACE fld1 WITH "12345678"
      mchan = DDEINITIATE("EXCEL","SHEET1")
      =DDEPOKE(mchan,"R1C1",fld1)

   With the above DDEPOKE() command FoxPro will send the FLD1 field
   contents to cell A1 in Sheet1 of Microsoft Excel.

3. Press ALT+TAB to switch to Microsoft Excel. Here you will see that the
   contents of FLD1 were transferred to cell A1 in Sheet1 as a numeric
   field.

In Microsoft Excel, to enter a number, string, or formula as text, you have to prefix the data with a single quotation mark. If you select cell A1, you will see that the Formula Bar does not display a single quotation mark before the cell's contents.

Additional reference words: FoxWin 2.50 2.50a 2.50b number format

KBCategory: kbinterop kbprg KBSubcategory: FxinteropDde

Last Reviewed: June 26, 1995