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 (834614)
The information in this article applies to:
- Microsoft Visual Basic 2005
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual C# 2005, Express Edition
- Microsoft Visual C# .NET (2003)
- Microsoft Visual C# .NET (2002)
SUMMARYThe 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). SYMPTOMSWhen the Microsoft Office Spreadsheet 11.0 ActiveX control
raises events, managed code cannot catch these events.CAUSEThe 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.RESOLUTIONTo resolve this problem, follow these steps: - Run the AxImp.exe tool on the OWC11.dll file.
- 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.
- Click Start, click Run,
and then type cmd in the Open
box.
- At the command prompt, locate the OWC11.dll file.
- 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.
- 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.
- 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
- 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
- Compile the modified AxOWC11.cs file.
- 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
- At the command prompt, change the directory to C:\Temp.
- 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.
- Test the modified AxOWC11.cs file.
- Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
- On the File menu, point to
New, and then click Project.
- 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. - On the View menu, click
Toolbox.
- 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. - 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.
- Add the Microsoft Office Spreadsheet
11.0 ActiveX control to the Form1 form.
- In Solution Explorer, expand
References under the project, and then click AxOWC11.
- On the View menu, click
Remove.
- Click References under Solution
Explorer, and then click Add Reference. The Add
Reference dialog box appears.
- Click Browse, locate and select the
AxOWC11.dll file, and then click OK.
- On the View menu, click
Code.
- Select AxSpreadsheet1 from the box in the Code view
window.
- 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 - Add the following code to this procedure:
MessageBox.Show("Test EndEdit")
- Build and run the application.
- On the Build menu, click Build
Solution.
- On the Debug menu, click
Start.
- 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.REFERENCESFor more information, visit the following Microsoft
Developer Network (MSDN) Web sites:
Modification Type: | Minor | Last Reviewed: | 10/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbOfficeWebSpread kbDLL kbActivexEvents kbEvent kbprb KB834614 kbAudDeveloper |
---|
|