COMEXCEL: Demonstrates an Automation Client Application with Compiler COM Support

Click to open or copy the COMEXCEL project files.

COMEXCEL is a stand-alone Automation (formerly OLE Automation) client. It creates a new Microsoft Excel spreadsheet and generates a pie chart of the data stored on that spreadsheet. This sample works only with Microsoft Excel, which exposes the dispinterfaces.

There is a Visual Basic project that controls the server in a way analogous to the COM code in Visual C++. You can compare the Visual Basic code with the code of this sample to see the similarities. You can use Visual Basic-specific object model documentation to write COM controllers in Visual C++.

To build this sample within Visual C++ for Excel 7.0, the file Xl5en32.olb must be in an accessible directory. To build this sample within Visual C++ for Excel 8.0, the files mso97.dll, vbeext1.olb, and excel8.olb must be in accessible directories. To ensure that a directory is accessible to the build process, select Options from the Tools menu and then the Directories tab. You can then review and add directories in which the build process can find project files.

If you get an access violation while running the COMEXCEL sample in Visual Basic  under Windows NT 4.0, please install the Windows NT Service Pack 3.

This sample demonstrates the following keywords:

dispinterface; #import; _com_ptr_t; _variant_t; _bstr_t; _com_error.

See also Compiler COM Support.