How to Initiate a DDE Channel to Microsoft Excel 5.0

Last reviewed: April 30, 1996
Article ID: Q117596
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6

SUMMARY

Unlike previous versions of Microsoft Excel, version 5.0 does not use individual worksheets. All worksheets in Microsoft Excel 5.0 are contained in workbooks. Therefore, the result of the DDEInitiate() command will vary, depending on the value of the second argument (the DDE topic).

MORE INFORMATION

Assuming two workbooks are open in Microsoft Excel (Book1 and Book2), and Book2 is active and both workbooks contain a worksheet named Sheet1, the results of the following four commands will be identical:

   chan=DDEInitiate("EXCEL","Book1:Sheet1")
   chan=DDEInitiate("EXCEL","Book2:Sheet1")
   chan=DDEInitiate("EXCEL","Book3:Sheet1")
   chan=DDEInitiate("EXCEL","Sheet1")

All four DDEInitiate() commands initiate a channel to Book2:Sheet1. This is the expected behavior for the second and fourth commands (in the fourth command, we can assume that the channel will go to Sheet1 in the active workbook). The result of the first and third commands is unexpected. This behavior occurs because the DDEInitiate() command can only initiate a channel to a specific worksheet in the currently active workbook. Therefore, in the first and third commands, the workbook name is ignored, and the DDEInitiate() command looks for the worksheet name in the currently active workbook. This behavior differs from that of previous versions of Microsoft Excel, with which you can initiate a channel to an inactive worksheet.

NOTE: In the above examples, if Sheet1 is deleted from Book2, regardless of which workbook is active, the following error message appears:

   Remote data not accessible. Start application 'EXCEL.EXE'?

The following command initiates a channel to the first (leftmost) worksheet in Book1, whether Book1 is active or not:

   chan=DDEInitiate("EXCEL","Book1")

To initiate a channel to Sheet1 in Book1, issue the following commands:

   syschan=DDEInitiate("EXCEL","System")
   =DDEExecute(syschan,'[ACTIVATE("Book1")]') && Book1 is now active
   ichan= DDEInitiate("EXCEL","Sheet1")
   =DDETerminate(syschan)  && we don't need it any more


Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b 2.60
Dynamic Data
Exchange
work sheet work book spreadsheet spread sheet
KBCategory: kbinterop kbprg
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: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.