Install | Use | Source | Download | Changes | License | Contact
This is an ATL implementation of Microsoft's ComAddin sample. The original sample was presented in raw C++.
The project requires Microsoft Visual C++ 6, ATL 3, and Word 2000.
The project is an add-in component for Microsoft Word 2000. It creates a commandbar, a button on the bar, and a sink for the button's click event. It can be easily modified for other Office 2000 applications. The project demonstrates:
The add-in is registered during the build process. To run it on another machine, enter
regsvr32 AtlAddIn.dllfrom the command line.
Start Microsoft Word 2000. You will be greeted by the add-in, and MyBar will appear as a floating command bar with My Button. You can dock the command bar by dragging it to the toolbar area of the Word interface.
You can hide the command bar by right-clicking it and unchecking MyBar on the context menu. You can then show it again by right-clicking in the toolbar area and checking MyBar.
Select Tools from the main menu and then Customize. Select 'COM Add-ins' from the Tools category. Drag the command to the Tools menu on Word's main menu bar. Now close the Customize dialog and select Tools from Word's main menu, and then 'Com Add-ins'. You can now 'disconnect' and 'connect' MyBar by unchecking and checking it. When the add-in is disconnected, MyBar can't be hidden and shown from the context menu.
source.zip contains a Microsoft Visual C++ 6.0 project. It is built with ATL 3.0, WTL 3.1, and the current Platform SDK.
Here is is the recipe for creating the project. Some of these procedures are matters of style rather than requirements.
#pragma warning(disable: 4146) #import "C:\Program Files\Microsoft Office\Office\MSO9.DLL" \ raw_interfaces_only, raw_native_types, named_guids, \ no_implementation using namespace Office;
The pragma disables the warning: "unary minus operator applied to unsigned type, result still unsigned".
The import directive defines the MS Office classes and interfaces. Note that the no_namespace attribute is excluded from the import directive, and the using directive is included afterwards. This resolves a collision with the DocumentProperties definition in WinSpool.h.
#define HR(_ex) { HRESULT _hr = _ex; if( FAILED(_hr) ) return _hr; }
Other than the sample itself, most of the Office add-in docs are written for Visual Basic.
SAMPLE: Comaddin.exe Office 2000 COM Add-In Written in Visual C++
Developing COM Add-Ins for Microsoft Office 2000
AtlAddin.zip (21k).
July 9, 2000
Enjoy.