Microsoft KB Archive/176265

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

Article ID: 176265

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Excel 97 Standard Edition

-



This article was previously published under Q176265







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

120802 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."

 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 </li> 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> Repeat steps 3-4.</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 executes, "Sheet1" should be changed to "New" in the workbook.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed this to be a problem in Microsoft Excel 97 for Windows.

<div class="references_section">