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.
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. 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
- On the File menu, click "Close and Return to Microsoft Excel."
- On the File menu, click Save. (Do not close Book1.xls.)
- Leaving Microsoft Excel open, start Microsoft Word.
- Repeat steps 3-4.
- 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
- On the File menu, click "Close and Return to Microsoft Word."
- 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.
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:
163435 VBA: Programming Resources for Visual Basic for Applications