How to Initiate a DDE Channel to Microsoft Excel 5.0

ID: Q117596

2.50 2.50a 2.50b 2.60 3.00 WINDOWS kbinterop kbprg

The information in this article applies to:

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
Keywords          : FxinteropDde 
Version           : 2.50 2.50a 2.50b 2.60 3.00
Platform          : WINDOWS

Last Reviewed: May 1, 1996