Excel fails when Automation add-In loads
This article was previously published under Q284876
When Microsoft Excel loads an Automation add-in during cell edit mode, Excel fails. This problem only occurs with Automation add-ins that have been Demand Loaded into Excel.
This problem can occur when an add-in loads if the add-in displays a form or dialog box, or if the add-in makes an Automation request to Excel that tries to change the state of Excel. The following list includes samples of Automation requests that may cause Excel to fail when it is called while an Automation add-in loads during cell edit mode:
- Programmatically change the current selection. For example:
- Call a property or method of an item in the Windows collection. For example:
Application.ActiveWindow.Zoom = 200
- Change an Excel setting such as the calculation mode. For example:
Application.CalculationMode = xlManual
Do not try the above-mentioned actions while your add-in loads. Add-in methods that are called during the load include the Initialize method and, if your Automation add-in implements the IDTExtensibility2 interface, the OnConnection and OnStartupComplete methods as well.
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Steps to Reproduce Problem
- Start a new ActiveX DLL project in Visual Basic.
- From the Project menu, click Project1 Properties. Change the Project Name to TestAddIn, and then click OK.
- Add the following code to the code module for Class1:
Private Sub Class_Initialize() MsgBox "Class_Initialize"End Sub
- Build TestAddIn.dll.
- In Excel, start a new workbook.
- In Microsoft Office Excel 2003 or in Microsoft Excel 2002, follow these steps:
- On the Tools menu, point to Add-Ins, and then click Automation.
- In the list, click TestAddIn.Class1, and then click OK.
- In the Add-Ins dialog box, click OK.
- Click the Microsoft Office Button, and then click Excel Options.
- Click the Add-Ins tab.
- In the Manage list, click Excel Add-ins, and then click Go.
- In the Add-Ins dialog box, click Automation.
- In the list, click TestAddin.Class1, and then click OK.
- Click OK.
- Type =a in any cell. A message box with the text "Class_Initialize" appears.
- Click OK to dismiss the message box. After a few seconds, Excel fails.
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
291392 INFO: Excel COM Add-ins and Automation Add-ins
com addin add-in xp shut down quit xl2002 xl2003 XL2007
Article ID: 284876 - Last Review: 02/09/2007 20:00:40 - Revision: 4.2
Microsoft Office Excel 2007, Microsoft Office Excel 2003, Microsoft Excel 2002 Standard Edition
- kbautomation kbbug kbpending KB284876