Work with Office Add-ins

Sometimes you might want to give access to interface controls that run code to modify documents. Aspose.Words API provides the webextensions module, which grants various classes to customize elements and attributes extending the XML vocabulary for representing Office Add-ins.

WebExtensions namespace can be conditionally divided into:

  • Objects for working with the task pane
  • Objects for working with web extensions

Using Task Panes

The task panes are interface surfaces that are displayed on the right side of the window in Microsoft Word. Task pane allows users to access interface controls that can run code to modify documents.

For example, using Aspose.Words API, you can add a task pane add-in and customize its appearance.

Using Web Extensions

Web Extensions are tools that expand the capabilities of Office applications and interact with Office document content. Web Extensions provide additional functionality to Office clients for improving user experience.

Aspose.Words provides the ability to add Web Extensions of the Task Pane type using the WebExtension and TaskPane classes, and also allows you to customize the pane and extension properties.

The following code example shows how to create task panes and add to web extension task panes with basic properties: 

To see a list of task pane add‑ins, use the web_extension_task_panes property.

The following code example shows how to get such a list of add‑ins:


FAQ

  1. Q: How do I add a task‑pane web extension to a document using Aspose.Words for Python via .NET?
    A: Create a WebExtension object, add a TaskPane to its TaskPanes collection, set the required properties (e.g., Id, Title, Visible), and then add the WebExtension to the document’s WebExtensionList. Finally, save the document.

  2. Q: How can I retrieve the list of task‑pane add‑ins that are already attached to a document?
    A: Use the Document.web_extension_task_panes property, which returns a collection of TaskPane objects. You can iterate over this collection to inspect each add‑in’s properties such as Id and Title.

  3. Q: Is it possible to modify the properties of an existing task‑pane after it has been added?
    A: Yes. After obtaining the TaskPane instance from the document’s web_extension_task_panes collection, you can change properties like Title, Visible, or DockState. The changes are persisted when the document is saved.

  4. Q: Are there any limits on the number of task‑pane web extensions that can be added to a single Word document?
    A: Aspose.Words does not impose a hard limit on the number of task‑pane extensions. The practical limit is determined by Word’s own constraints and the size of the document’s XML, so adding a reasonable number of panes is safe.

  5. Q: How do I remove a specific task‑pane web extension from a document?
    A: Locate the desired TaskPane in the Document.web_extension_task_panes collection and call RemoveAt(index) or Remove(taskPane) on the collection. After removal, save the document to persist the change.