For the user to access add-in functionality, the add-in should add a new menu item or a
new toolbar button to application. When the user selects this menu item or button, the
add-in should use the Microsoft Office Object Model to obtain a pointer to the active
document. It should then call the active document's ExportAsFixedFormat method with
an IUnknown interface pointer that supports the IMsoDocExporter interface through a
call to the QueryInterface method. The object model parameter for the interface pointer
is a VARIANT with VT_UNKNOWN type.
Note
For OneNote, the add-in calls the Publish method with a string parameter that is the class ID of
the add-in's implementation of the IMsoDocExporter interface. OneNote then calls
CoCreateInstance with the class ID to get an IUnknown interface pointer from the add-in's class
factory.
After Publisher has a pointer to the IMsoDocExporter interface, it calls back the add-in
through the methods exposed by IMsoDocExporter. Through these callbacks, Word
provides the add-in with document content and other information about the document.
An excellent source of information about building COM add-ins for Microsoft Office
applications is the codeproject.com article Building an Office2K COM Add-in with
VC++/ATL .
The IMsoDocExporter interface exposes the following methods.
Table 1. Methods exposed by the IMsoDocExporter interface
Method Description
HrCreateDoc Called at the start of the fixed-format export process.
HrAddPageFromEmf Called to pass the add-in an enhanced metafile (EMF) that
represents a rendered view of the content to export.
HrAddDocumentMetadataString Called to specify string-format metadata for the document.
HrAddDocumentMetadataDate Called to specify date-format metadata for the document.
HrSetDefaultLcid Called to specify the default locale ID (LCID) for the content to
ﾉ Expand table
IMsoDocExporter
ﾉ Expand table