XL: DDE Poke to Microsoft Excel Workbook Fails

Last reviewed: September 2, 1997
Article ID: Q115467

The information in this article applies to:

  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for Windows 95, version 7.0

SYMPTOMS

When you use the dynamic data exchange (DDE) Poke statement to insert data in a Microsoft Excel version 5.0 workbook, the information is not inserted, and you may receive an error message in the application that you are using to send the data.

CAUSE

This behavior occurs because the DDE command "times out" when it's opening the workbook file that you want to send the information to. The time it takes to initialize the sheets contained in a Microsoft Excel 5.0 workbook file may cause a DDE Initiate command to time out.

NOTE: This is not a problem when you send data to a worksheet in Microsoft Excel version 4.0.

WORKAROUNDS

To avoid this problem, start Microsoft Excel and open the workbook that you want to send information from BEFORE you use the DDE Poke statement to insert data in the workbook. The following is an example of using this method.

Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This macro is provided 'as is' and Microsoft does not guarantee that the following code can be used in all situations. Microsoft does not support modifications of the code to suit customer requirements for a particular purpose.

Microsoft Word for Windows Macro

   Sub Main
      Q$ = Chr$(34)
      ' Initiate DDE conversation using System topic
      Channel = DDEInitiate("EXCEL", "System")
      ' Open workbook file
      DDEExecute Channel, "[OPEN(" + Q$ + "C:\EXCEL\BOOK1.XLS" + Q$ + ")]"
      ' Initiate DDE conversation using open workbook file
      Channel2 = DDEInitiate("excel", "C:\EXCEL\BOOK1.XLS")
      ' Insert data in workbook
      DDEPoke Channel2, "R1C1", "Total: $1,434"
      DDETerminate Channel
      DDETerminate Channel2
   End Sub

Note that if the application that you are using to send data to Microsoft Excel supports Microsoft Visual Basic Programming System, Applications Edition, such as Microsoft Project 4.0, you can use the properties and methods of the objects exposed by Microsoft Excel to open the workbook and insert the information.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

If you use one of the DDEPoke help topic examples found in the WordBasic Help file, you receive the following error message if the workbook file is not currently open in Microsoft Excel:

   WordBasic Err=500
   Cannot Initiate Link

Use the workaround above to avoid receiving this error message,.


Additional query words: 2.00 4.00 5.00 5.00c 6.00 6.00a 7.00
officeinterop ole automation
Keywords : kbprg SynFnc kbprg
Version : 5.00 5.00c 7.00
Platform : WINDOWS


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: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.