Web Extensions
Web Extensions
This guide shows how to read and modify Office Add-in task pane metadata embedded in a .docx file with Aspose.Words FOSS for .NET. Aspose.Words FOSS for .NET can read and modify the web extension (Office Add-in) task panes embedded in a .docx file — the metadata that associates a document with an Office Add-in and binds it to document data — through Document.WebExtensionTaskPanes and the TaskPane/WebExtension object model.
Task Panes
Document.WebExtensionTaskPanes returns a TaskPaneCollection of TaskPane objects. Each TaskPane describes where and how an add-in’s pane is docked: DockState (a TaskPaneDockState of Right or Left), Row, Width, IsLocked, and IsVisible, plus a WebExtension property linking to the add-in itself.
Web Extension Identity and References
WebExtension identifies the add-in via Id and IsFrozen, and its Reference property (a WebExtensionReference) exposes Id, Version, Store, and StoreType (a WebExtensionStoreType such as SPCatalog, Exchange, or FileSystem) describing where the add-in is distributed from. AlternateReferences holds a WebExtensionReferenceCollection of fallback references.
Bindings and Custom Properties
WebExtension.Bindings is a WebExtensionBindingCollection of WebExtensionBinding objects, each constructed as new WebExtensionBinding(id, bindingType, appRef) and linking part of the document’s data to the add-in via a WebExtensionBindingType (Matrix, Table, or Text). WebExtension.Properties is a WebExtensionPropertyCollection of simple WebExtensionProperty name/value pairs, constructed as new WebExtensionProperty(name, value), used for add-in-specific custom settings that don’t warrant a full binding.
Collection Membership
TaskPaneCollection, WebExtensionBindingCollection, WebExtensionPropertyCollection, and WebExtensionReferenceCollection all share the same base collection behavior: Add(item), Clear(), Remove(index), GetEnumerator(), and Count.
Tips and Best Practices
- Check
TaskPane.IsVisiblebefore assuming an add-in’s pane is currently shown to the user — a task pane can be registered but hidden. WebExtensionReference.StoreTypetells you where an add-in was sourced from (catalog, Exchange, file system, registry); use it to distinguish first-party from sideloaded add-ins.- Bindings link a specific
WebExtensionBindingType(matrix, table, or plain text) to document data — check the binding type before assuming what shape of data an add-in expects. - Use
WebExtension.Propertiesfor simple name/value add-in configuration values rather than trying to store them elsewhere in the document.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
Document.WebExtensionTaskPanes is empty | The document has no Office Add-ins registered | Confirm the source .docx actually embeds a task pane before assuming the API is broken |
| Can’t tell which store an add-in came from | StoreType not checked | Read WebExtensionReference.StoreType alongside Store for the full picture |
| Binding data doesn’t match expectations | Binding type mismatch | Check WebExtensionBinding.BindingType (Matrix, Table, Text) before consuming bound data |
FAQ
How do I find all Office Add-ins registered in a document?
Enumerate Document.WebExtensionTaskPanes (a TaskPaneCollection); each TaskPane.WebExtension gives you the add-in’s identity and configuration.
Can I add a new web extension binding or property with this API?
Yes — the collections (WebExtensionBindingCollection, WebExtensionPropertyCollection, etc.) support Add(), so you can construct and add new WebExtensionBinding/WebExtensionProperty objects to an existing WebExtension.
What does WebExtensionBinding actually bind?
It links a portion of the document’s data to the add-in, using a WebExtensionBindingType (Matrix, Table, or Text) to describe the shape of that data.
How do I read custom add-in settings stored in the document?
Iterate WebExtension.Properties (a WebExtensionPropertyCollection); each WebExtensionProperty exposes a Name/Value pair.
API Reference Summary
| Class / Method | Description |
|---|---|
Document.WebExtensionTaskPanes | TaskPaneCollection of task panes registered in the document |
TaskPane | One add-in pane: DockState, Row, Width, IsVisible, IsLocked, WebExtension |
WebExtension | Add-in identity: Id, IsFrozen, Reference, Bindings, Properties |
WebExtensionReference | Add-in source: Id, Version, Store, StoreType |
WebExtensionBinding | Links document data to the add-in via WebExtensionBindingType |
WebExtensionProperty | Custom add-in setting as a Name/Value pair |