Office 2007 New Extensibility Interfaces
Office 2007 introduced a set of new extensibility interfaces. Prior to Office 2007, there were several extensibility interfaces, which all behaved differently, required different development techniques, different deployment/registration and different runtime lifetime characteristics. These included ISmartTagRecognizer, ISmartTagAction, ISmartDocument and IRtdServer. The only interface that was usefully implementable in a COM add-in was IDTExtensibility2 – and, of course, the add-in had to implement this interface by definition.
One of the nice things about the new extensibility interfaces in Office 2007 is that they are all implementable in a COM add-in (either unmanaged or managed, and either a shared add-in or a VSTO add-in). This convergence is by design – its something that the programmability team in Office felt was particularly important in the evolving story of Office as a development platform. This design means that going forwards you only have to worry about one development model, one deployment model, and one runtime behavior model. The new interfaces are listed below – there are 8 of them (or 7 ½ depending on how you look at it - more on this below):
Interface |
Office hosts that support this interface |
ICustomTaskPaneConsumer |
Access, Excel, InfoPath, Outlook, PowerPoint, Word |
IRibbonExtensibility |
Access, Excel, Outlook, PowerPoint, Word |
FormRegionStartup |
Outlook |
IBlogExtensibility |
Word |
IBlogPictureExtensibility |
Word |
EncryptionProvider |
Excel, PowerPoint, Word |
SignatureProvider |
Excel, PowerPoint, Word |
IDocumentInspector |
Excel, PowerPoint, Word |
Why 7 ½? Well, IDocumentInspector is listed here for completeness – actually, it's an anomaly. You can implement IDocumentInspector in an add-in, but you can also implement it in a regular (non-add-in) class library or DLL. You don't have to implement it in an add-in. Office does not load a document inspector in the same way as an add-in – instead, it cocreates the class that implements IDocumentInspector using traditional COM registration. Indeed, if you do choose to implement this interface in an add-in, your add-in DLL will get loaded twice by Office – once through the normal add-in load path, and a second time when Office cocreates it independently.
All the other new interfaces are intended to be implemented in an add-in, and are used in the same way by Office. That is, Office loads an add-in and then queries the add-in to see if it implements each of the new interfaces. For each interface, if the add-in confirms that it does implement it, Office will subsequently make callbacks on the interface. This convergence on a single standard model is very refreshing. However, note that there are still some differences in the way that Office uses the interfaces. For example, Office queries the add-in for each interface at different times:
Interface |
When does Office query for this interface? |
ICustomTaskPaneConsumer |
When Office loads or connects the add-in. |
IRibbonExtensibility |
When Office loads or connects the add-in. |
FormRegionStartup |
When Outlook opens an inspector for a message type for which this add-in is registered as a custom form region provider. |
IBlogExtensibility |
When the user creates a new blog post and selects/registers a blog account. |
IBlogPictureExtensibility |
When the user selects/registers a blog account and selects the Picture Options dialog. |
EncryptionProvider |
When the user selects the Office button | Prepare | Encrypt. |
SignatureProvider |
When the Insert menu is activated. |
IDocumentInspector |
(never) |
Another difference is that for all interfaces apart from IRibbonExtensibility, Office treats the interface as a standard COM interface. That is, Office only calls methods defined in the interface. For IRibbonExtensibility, on the other hand, Office treats this as an automation interface, and will make calls to any number of methods that you define in your object (and your Ribbon XML) but not in the IRibbonExtensibility interface. This "arbitrary callback" model is dramatically different from most other things in Office development, although it is similar to how the old ISmartDocument interface was used (and wasn't that a fun interface to work with? J).
In a previous post, Low-level support for ICustomTaskPaneConsumer, IRibbonExtensibility, FormRegionStartup, etc, I talked about how the VSTO runtime supports the new extensibility interfaces as part of its low-level infrastructure. Note, however, that VSTO only supports 3 of the new interfaces: ICustomTaskPaneConsumer, IRibbonExtensibility and FormRegionStartup. The other interfaces may or may not work with the VSTO runtime, but we have not done any extensive testing on them, so we cannot support them. Also, of course, VSTO provides both design-time and runtime support for the 3 supported interfaces at a higher level, in addition to the low-level support – and it's obviously easier to use the higher-level support wherever it meets your needs. You can also mix the high and low level support if you want to – for example, use the high-level support for custom task pane and the low-level support for Ribbon customization in the same add-in. The underlying Office interface querying mechanism and the VSTO low-level infrastructure are both designed to be open-ended. That is, the design should support any new interface that Office might introduce in later releases.
Comments
- Anonymous
July 05, 2007
In our spare time, Misha and I have been working on and off on the COM Shim and associated COM Shim Wizards - Anonymous
July 05, 2007
In our spare time, Misha and I have been working on and off on the COM Shim and associated COM Shim Wizards - Anonymous
September 17, 2007
Hi, Andrew. I'm now examining the extensibility of blog picture provider for Word 2007 in .NET. Now I came across a parameter named Image of type System.Object in IBlogPictureExtensibility.PublishPicture() method. In MSDN, it is said that the image is represented as a PNG format, but how can I make use of it in .NET? - Anonymous
January 27, 2008
I have created an Addin which displays a custom task pane at the bottom. This successfully builds and displays in Outlook 2007.Here are the issues :(a) I dont want that the user should be able to close this Customk Task Pane. What do i need to do to achieve this ?(b) The CustomTaskPane comes at the bottom. I want to dock it to Left Bottom of the Outlook Explorer window (Where you see the mailBox folders and Shortcuts for Notes, Calender etc. How can i do this ?(c) The above interfaces exists for VSTO 3.0. Right ?ThanksKulvinder Singh - Anonymous
August 27, 2008
The comment has been removed - Anonymous
September 03, 2008
User - it seems that my table (and some of our documentation) is incorrect. Turns out PowerPoint did not implement this feature, so you can only add signature lines to Word and Excel documents. This is mentioned in the online help here: http://office.microsoft.com/en-us/help/HA100997681033.aspx.