Microsoft KB Archive/213677

From BetaArchive Wiki
Knowledge Base


XL2000: "Run-Time Error '4599'" Running DDE Macro to Control Excel

Article ID: 213677

Article Last Modified on 11/23/2006



APPLIES TO

  • Microsoft Excel 2000 Standard Edition



This article was previously published under Q213677


SYMPTOMS

When you use dynamic data exchange (DDE) to control Microsoft Excel from another program, you 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 message appears, 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 professionals 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 a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

If the application supports Automation, it is recommended that you use Automation to control Microsoft Excel instead of DDE.

To work around this behavior by 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 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. In Word, press ALT+F11. In the Visual Basic Editor, on the Insert menu, click Module.
  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 runs, "Sheet1" should be changed to "New" in the workbook.

For additional information about getting help with Visual Basic forApplications, click the article number below to view the article in the Microsoft Knowledge Base:

226118 OFF2000: Programming Resources for Visual Basic for Applications


STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

Keywords: kbbug kberrmsg kbinterop kbpending kbprogramming KB213677