You are currently offline, waiting for your internet to reconnect

PRB: Error Message "Cannot insert object" in Excel

This article was previously published under Q171280
The following error message appears when you attempt to useyour Visual C++ control in Microsoft Excel 97, Microsoft Excel 2000, or Microsoft Excel 2002:
Cannot insert object
This error occurs if you created a control in Visual C++, manually changedthe _wVerMajor and/or _wVerMinor variables, and didn't change thecorresponding type library version number in the .odl file of your project.This occurs because Excel 97, Excel 2000, and Excel 2002 explicitly check to see if these two variables are equivalent in the registry.
To resolve this problem, you either have to change the version() attributein your .odl file to reflect the current state of the _wVerMajor and_wVerMinor variables at compile-time, or specifically modify the registryentry HKCR\TypeLib\<Your TypeLib>\X.Y, where X and Y represent your majorand minor version numbers respectively.
This behavior is by design.

Steps to Reproduce Behavior

  1. Create a new MFC ActiveX ControlWizard project, and click Finish.
  2. Open your <ProjectName>.cpp file, and find the variables _wVerMajor and _wVerMinor.
  3. Change the _wVerMajor variable to 3.
  4. Compile the project.
  5. Open Excel.
  6. Try to insert your control using the Object option under the Insertmenu, or, click Toolbars on the View menu, and click to select the Control Toolbox option to display that toolbar. On that toolbar, click the "more controls" button and find your control in the list box. Click it, and then draw your control on the worksheet.
  7. The "Cannot insert object" error message appears.
For more information about the wVerMajor or wVerMinor global constants,search for "wVerMajor" or "wVerMinor" in Visual C++ Help.

For more information about ODL (Object Description Language) files and theversion() attribute, search for "ODL" or "ODL Attributes" in Visual C++Help.

Article ID: 171280 - Last Review: 01/20/2007 02:23:17 - Revision: 4.3

  • Microsoft Excel 2000 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Excel 2002 Standard Edition
  • Microsoft Excel 97 Standard Edition
  • kberrmsg kbprb KB171280