From the course: Microsoft Office Add-Ins for Developers

The Office.js libraries

- [Instructor] Remember I said that we can easily get to the contents of the document we are working on. We do this through the Office.js API. Which is the bridge to the current document. This is a java script library that gives us a rich set of functions to get and set the content of the document. In fact, it is the initialized method of the Office.js API that we are going to override in order to be able to start running our code when the add-in starts. And if, by the way, we don't respond promptly, within five seconds the framework will shut our add-in down so we shouldn't start any long initialization process or calculation, just return straight away. Once we have called the initialized method, we might want to check for the support if using UI Office.js capabilities. Using the requirements is set supported operation. Some of the APIs are generic, but a lot are specific for each Office application and many of them follow this pattern where we get context using the run method. You then get a context to load properties you need to work with. Then, call the context Sync method to execute a batch of operations. Then, call the context Sync method to execute a batch of operations and use the return promise to get results for a previous operation and perform any new operations and, of course, catch any errors. We'll talk more about Office.js later in the course, but this shows a fraction of the API surface for version 1.1 of Word. Don't worry too much about the details, but you can see that a lot of the functionality of the Office applications is exposed. The intention is that anything you can do with the UI should be possible through the API, but this is a longterm goal for the Office add-ins development team. Although these APIs are already very powerful, there is still a long way to go.

Contents