Microsoft KB Archive/213677

= 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:

https://partner.microsoft.com/global/30000104

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

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

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."  Start Microsoft Excel. Save the new workbook as Book1.xls.

Make sure that a sheet named Sheet1 exists. Press ALT+F11 to start the Visual Basic Editor. On the Insert menu, click Module.  Type the following code in the new module sheet: Sub Change_Name Sheets("Sheet1").Name = "New" End Sub  On the File menu, click Close and Return to Microsoft Excel.</li> On the File menu, click Save. (Do not close Book1.xls.)</li> Leaving Microsoft Excel open, start Microsoft Word.</li> In Word, press ALT+F11. In the Visual Basic Editor, on the Insert menu, click Module.</li>  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 </li> On the File menu, click Close and Return to Microsoft Word.</li> 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.</li></ol>

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

<div class="status_section">

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

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.