CREATING WORD ADD-IN USING JAVASCRIPT (PART 1)
Lets start with word add-in overview
If you are looking to build a solution that extends the functionality of word, like one that involves automated document assembly, or to create a solution that binds to and access data from word document to some other data sources, then you can use office add-ins platforms, which includes Word javaScript API and Office javaScript API, to extend the functionalities of word client running on Windows desktop, on a Mac or in cloud. It allows you to use the add-in commands that extends Word-UI and launch taskpanes that runs JavaScript that interacts with the content of word document. Any code that runs on browser, runs in add-in too. Add-in that interacts with word document sends request to word object and synchronizes object’s state.
You can host your add-in in any web server technology like ASP.NET, NodeJS or Python and use any frontend technology among React, Angular, Ember, Backbone or plain VanillaJS to build your client side solution.
JavaScript APIs for Word
There are two sets of JavaScript APIs to interact with objects and metadata in Word document.
- Common API : This API was introduced in Office 2013. Many of the objects in the Common API can be used in add-ins hosted by two or more Office clients. This API uses callbacks extensively.
- Word JavaScript API :This is the strongly typed object model that can be used to create add-ins that targets Word 2016 on Mac and Windows.It uses promises and provides access to different word objects like body, document, paragraphs, content controls and inline pictures.
Microsoft has launched three version of Word JavaScript API. There are many versions of Office across multiple platforms and they all does not support Office JavaScript APIs., for which Microsoft office provides a system called requirement sets to help you determine whether the Office hosts supports the capabilities you need in your add-in.
You can view further details on API requirements sets for other office platforms here.
It is recommended to start with Word JavaScript APIs because its object models are easier to use and understand.