The Visual Studio .NET or Visual Studio 2005 client application cannot catch the events that are raised by an Office Spreadsheet 11.0 ActiveX control

Article translations Article translations
Article ID: 834614 - View products that this article applies to.
Expand all | Collapse all

On This Page

SUMMARY

The Microsoft Visual Studio .NET or Visual Studio 2005 client application cannot catch the events that are raised by an existing ActiveX control (Microsoft Office Spreadsheet 11.0).

SYMPTOMS

When the Microsoft Office Spreadsheet 11.0 ActiveX control raises events, managed code cannot catch these events.

CAUSE

The IChartInterface interface of the OWC11.dll file has dispatch identifiers (DISPIDs) on its methods. When you derive the event listener class from the IChartInterface interface, the overridden methods do not support the DISPIDs of the IChartInterface interface. When the Microsoft Office Spreadsheet 11.0 tries to raise the event, the event listener class cannot find the DISPIDs.

RESOLUTION

To resolve this problem, follow these steps:
  1. Run the AxImp.exe tool on the OWC11.dll file.
    1. Locate the OWC11.dll file. The OWC11.dll file is a DLL for the Microsoft Office Spreadsheet 11.0 ActiveX control. The OWC11.dll file is typically located in the following folder: C:\Program Files\Common Files\Microsoft Shared\Web Components\11.
    2. Click Start, click Run, and then type cmd in the Open box.
    3. At the command prompt, locate the OWC11.dll file.
    4. Type aximp /source OWC11.dll at the command prompt. You notice that the AxOWC11.dll file and the AxOWC11.cs file are generated and are placed in the same folder where this command is executed.

      The AxImp.exe file converts the whole ActiveX control type library and produces a set of assemblies that contain the common language runtime metadata and control implementation for the types that are defined in the original type library.
  2. Modify the AxOWC11.cs file. To do this, add the code in the following steps to modify all the Control classes and the corresponding EventMulticaster classes in the source file that is generated.
    1. Set the ToolboxItem attribute to true in the generated class file. To do this Add the following code before the Control classes:
      [System.ComponentModel.ToolBoxItem(True)]
      The Control classes are as follows:
      • AxChartSpace
      • AxSpreadsheet
      • AxDataSourceControl
      • AxRecordNavigationControl
      • AxPivotTable
    2. Add the following code above the EventMulticaster classes:
      [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
      The EventMulticaster classes are as follows:
      • AxChartSpaceEventMulticaster
      • AxSpreadsheetEventMulticaster
      • AxDataSourceControlEventMulticaster
      • AxRecordNavigationControlEventMulticaster
      • AxPivotTableEventMulticaster
  3. Compile the modified AxOWC11.cs file.
    1. Locate, and then copy the assemblies that are referenced in the AxOWC11.cs file to a folder. The referenced assemblies are as follows:
      • Microsoft.Office.Interop.Owc11.dll
      • Adodb.dll
      • Mscomctl.dll
      • Msdatasrc.dll
    2. At the command prompt, change the directory to C:\Temp.
    3. To compile the AxOWC11.cs file, type the following command at the command prompt:
      csc /t:library  /lib:c:\Temp /r:Microsoft.Office.Interop.Owc11.dll;ADODB.dll;MSCOMCTL.DLL;msdatasrc.dll AxOWC11.cs
      
      Note Temp is a folder that you create in your hard disk drive. This folder contains the referenced assemblies and the AxOWC11.cs file.
  4. Test the modified AxOWC11.cs file.
    1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
    2. On the File menu, point to New, and then click Project.
    3. Under Project Types, click Visual Basic Projects, and then click Windows Application under Templates.

      Note In Visual Studio 2005, click Visual Basic under Project Types.
    4. On the View menu, click Toolbox.
    5. Right-click the toolbox, and then click Add/Remove Items. The Customize Toolbox dialog box appears.

      Note In Visual Studio 2005, right-click the toolbox, and then click Choose Items.
    6. On the COM Components tab, click to select Microsoft Office Spreadsheet 11.0, and then click OK. The Microsoft Office Spreadsheet 11.0 ActiveX control is added to the toolbox.
    7. Add the Microsoft Office Spreadsheet 11.0 ActiveX control to the Form1 form.
    8. In Solution Explorer, expand References under the project, and then click AxOWC11.
    9. On the View menu, click Remove.
    10. Click References under Solution Explorer, and then click Add Reference. The Add Reference dialog box appears.
    11. Click Browse, locate and select the AxOWC11.dll file, and then click OK.
    12. On the View menu, click Code.
    13. Select AxSpreadsheet1 from the box in the Code view window.
    14. Select the EndEdit event from the second box in the Code view window. The following procedure is added to the Code view:
      Private Sub AxSpreadsheet1_EndEdit(ByVal sender As Object, ByVal e As AxMicrosoft.Office.Interop.Owc11.ISpreadsheetEventSink_EndEditEvent) Handles AxSpreadsheet1.EndEdit
      
          End Sub
    15. Add the following code to this procedure:
      MessageBox.Show("Test EndEdit")
  5. Build and run the application.
    1. On the Build menu, click Build Solution.
    2. On the Debug menu, click Start.
    3. Edit the cell in the Microsoft Excel spreadsheet that appears, and then click the next cell in the Excel spreadsheet. You receive a dialog box with the following text:
      Test EndEdit

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Create a Windows application.
    1. Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
    2. On the File menu, point to New and then click Project.
    3. Under Project Types, click Visual Basic Projects, and then click Windows Application under Templates.

      Note In Visual Studio 2005, click Visual Basic under Project Types.
  2. Add the Microsoft Office Spreadsheet ActiveX control to the Form1 form.
    1. On the View menu, click Toolbox.
    2. Right-click the toolbox, and then click Add/Remove Items. The Customize Toolbox dialog box appears.

      Note In Visual Studio 2005, right-click the toolbox, and then click Choose Items.
    3. On the COM Components tab, click to select Microsoft Office Spreadsheet 11.0, and then click OK. The Microsoft Office Spreadsheet 11.0 ActiveX control is added to the toolbox.
    4. Add the Microsoft Office Spreadsheet 11.0 ActiveX control to the Form1 form.
  3. Add the code to the EndEdit event.
    1. On the View menu, click Code.
    2. Select AxSpreadsheet1 from the box in the Code view window.
    3. Select the EndEdit event from the second box in the Code view window. The following procedure is added to the Code view:
      Private Sub AxSpreadsheet1_EndEdit(ByVal sender As Object, ByVal e As AxMicrosoft.Office.Interop.Owc11.ISpreadsheetEventSink_EndEditEvent) Handles AxSpreadsheet1.EndEdit
      
          End Sub
    4. Add the following code to this procedure:
      MessageBox.Show("Test EndEdit")
  4. Build the application, and then and run the application.
    1. On the Build menu, click Build Solution.
    2. On the Debug menu, click Start.
    3. Edit the cell in the Excel spreadsheet that appears. Click the next cell of the Excel spreadsheet. The dialog box that indicates that the event is not fired does not appear.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites:
Windows Forms ActiveX Control Importer (Aximp.exe)
http://msdn2.microsoft.com/en-us/library/8ccdh774(vs.71).aspx
Web components and controls
http://msdn2.microsoft.com/en-us/library/aa165059(office.10).aspx
Working with ActiveX controls
http://msdn2.microsoft.com/en-us/library/y7c25adt(vs.71).aspx
Standard DISPIDS
http://msdn2.microsoft.com/en-us/library/ms694489.aspx

Properties

Article ID: 834614 - Last Review: November 27, 2007 - Revision: 3.5
APPLIES TO
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
  • Microsoft Visual C# 2005 Express Edition
  • Microsoft Visual C# .NET 2003 Standard Edition
  • Microsoft Visual C# .NET 2002 Standard Edition
Keywords: 
kbvs2005swept kbvs2005applies kbofficewebspread kbdll kbactivexevents kbevent kbprb KB834614

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com