XL97: "Run-time error '4599'" Running DDE Macro to Control Excel

Last reviewed: February 27, 1998
Article ID: Q176265
The information in this article applies to:
  • Microsoft Excel 97 for Windows

SYMPTOMS

When you use dynamic data exchange (DDE) to control Microsoft Excel from another program, you will see the following error message when you try to rename a sheet in a workbook:

   Run-time error '4599': Process failed in other application

When you activate Microsoft Excel after the error, the sheet tab is selected as if you are ready to change it.

CAUSE

This error occurs when you are trying to rename a sheet by using the DDEExecute method with Workbook.Name() as the command in a Microsoft Visual Basic for Applications procedure or macro from another program.

RESOLUTION

Microsoft provides programming 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 article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

If the application supports Automation, it is recommended that you use Automation to control Microsoft Excel instead of DDE. For more information about controlling programs through Automation, click the Office Assistant, type "Automation," click Search, and then click to view "Controlling one Microsoft Office application from another."

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Excel or Visual Basic Help are not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office
               Program or Component

To work around this behavior using DDE, write a Visual Basic procedure or macro in Microsoft Excel to rename the sheet and have the DDE procedure run the Microsoft Excel procedure or macro to change the sheet name.

The following example uses Microsoft Word 97 as the program that contains the DDE macro that controls Microsoft Excel. It assumes that you are initiating a DDE channel to an existing workbook ("Book1.xls") and you are changing "Sheet1" to "New."

  1. Start Microsoft Excel.

  2. Save the new workbook as Book1.xls.

    Make sure that a sheet named Sheet1 exists.

  3. Press ALT+F11 to start the Visual Basic Editor.

  4. On the Insert menu, click Module.

  5. Type the following code in the new module sheet:

           Sub Change_Name()
              Sheets("Sheet1").Name = "New"
           End Sub
    
    

  6. On the File menu, click "Close and Return to Microsoft Excel."

  7. On the File menu, click Save. (Do not close Book1.xls.)

  8. Leaving Microsoft Excel open, start Microsoft Word.

  9. Repeat steps 3-4.

  10. Type the following code in the new module sheet:

           Sub DDE_to_XL()
    
              ' Opens a DDE channel to Book1.xls in Microsoft Excel.
              Chan = DDEInitiate(App:="Excel", Topic:="book1.xls")
    
              ' Sends a DDE command to Microsoft Excel to run the
              ' Change_Name macro.
              DDEExecute Channel:=Chan, Command:="[Run(" & Chr(34) & _
                 "Change_Name" & Chr(34) & ")]"
    
              ' Closes the DDE channel to Book1.xls in Microsoft Excel.
              DDETerminate Channel:=Chan
    
           End Sub
    
    

  11. On the File menu, click "Close and Return to Microsoft Word."

  12. On the Tools menu, point to Macro, and then click Macros. In the Macros dialog box, click "DDE_to_XL," and then click Run.

    After the macro executes, "Sheet1" should be changed to "New" in the workbook.

STATUS

Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

REFERENCES

"Visual Basic User's Guide," version 5.0, Chapter 10, "Controlling and Communicating with Other Applications"

"Microsoft Excel/Visual Basic Programmer's Guide," version 7.0, Chapter 10, "Communicating with Other Applications"

For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications


Additional query words: XL97 kbmacro
Keywords : kbinterop xlwin offinterop xl97vbmigrate AutoGnrl
Version : WINDOWS:97
Platform : WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


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