How to Close Microsoft Excel Using DDE Commands in FoxPro

Last reviewed: April 29, 1996
Article ID: Q95718
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

The code below demonstrates how use dynamic data exchange (DDE) commands to close Microsoft Excel from within FoxPro for Windows. The commands below assume that the DDE link with Microsoft Excel has already been established using the DDEInitiate() command.

MORE INFORMATION

To close Microsoft Excel without saving changes:

   =DDEExecute(<Channel>,"[Error(False)]")
   =DDEExecute(<Channel>,"[Quit()]")

To close Microsoft Excel and be prompted to save changes:

   =DDEExecute(<Channel>,"[Close.All()]")
   =DDEExecute(<Channel>,"[Error(False)]")
   =DDEExecute(<Channel>,"[Quit()]")

To close Microsoft Excel and save changes without being prompted:

   =DDEExecute(<Channel>,"[Save()]")
   =DDEExecute(<Channel>,"[Close.All()]")
   =DDEExecute(<Channel>,"[Error(False)]")
   =DDEExecute(<Channel>,"[Quit()]")

   NOTE: The above code to close Microsoft Excel and save changes
   without prompting will work if only the top spreadsheet needs
   saving. If additional spreadsheets also need to be saved,
   prompting will occur.


Additional reference words: FoxWin 2.50 2.50a
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 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.