This step-by-step article describes how to modify the class wrappers for Microsoft Office 2003 Web Components. It then describes how to regenerate the class wrappers so that you can manage their events in an application that you create by using Microsoft Visual Studio .NET.
By default, the class wrappers that Microsoft Visual Studio .NET generates do not permit you to handle events for the following Office 2003 Web components:
To handle the events for these components, you can modify the source code for the class wrappers, and then recompile the code.
Microsoft Visual Studio .NET generates an event listener class that implements an event interface. This event listener class is passed to the Office Web Components (OWC). The OWC then calls the QueryInterface method for the IDispatch interface, instead of calling the event interface. However, the IDispatch interface for the generated class does not contain the dispatch identifiers (DISPIDs) for the events.
To resolve this issue, you can mark the generated class by using the ClassInterfaceType.None value to force COM interop to return IDispatch for the interface instead of for the class. The IDispatch interface contains the event DISPIDs.
Steps to Modify and to Rebuild the Class Wrappers
Start the Visual Studio .NET command prompt.
At the command prompt, do the following:
Create a new directory named owc11, and then change to that directory:
Generate the source code in C# for the Microsoft Windows Forms wrapper:
Note You receive the following CS0108 error message:
The keyword new is required
You may ignore this error.
Start Visual Studio .NET.
Add your newly-compiled AxOWC11.dll to the Toolbox:
On the Tools menu, click Customize Toolbox (in Visual Studio .NET 2002), or click Add/Remove Toolbox Items (in Visual Studio .NET 2003), and then click the .NET Framework Components tab.
On the .NET Framework Components tab, click Browse.
In the File name text box, type c:\owc11\axowc11.dll. Click Open.
Click OK to close the Customize Toolbox dialog box.
When you create a new Microsoft Visual Basic .NET project or a new Microsoft Visual C# .NET project, notice that the list of controls on the General tab in the Toolbox contains the AxChartSpace control, the AxPivotTable control, and the AxSpreadsheet control. You can now add these components to your forms.
For additional information about managing events for the Office XP Web Components by using Visual Studio .NET, click the following article numbers to view the articles in the Microsoft Knowledge Base:
328275 HOW TO: Handle Events for the Office Web Components in Visual Studio .NET