Office Development – Word Add-in, minimal code

So far it has been fairly complex, installing lots of components and doing all sorts of things before you get things to work. But what do you need for code to do just the minimal thing in a Word Add-in?

Initially it is said that a context is required by requesting a new context:

var ctx = new Word.RequestContext();

With this context you can do things the things you’d like to do.

function MinimalWordmethod() {
  
// Create the client request context. You’ll do this for al Word add-ins.

   var ctx = new Word.RequestContext();

   // Do your things here, such as ..
   var range = ctx.document.getSelection();

   ctx.executeAsync()
     
.then(function () {})
     
.catch(function(error){
        
console.log("ERROR: " + JSON.stringify(error));
     
});
}

Interesting part is that this RequestContext is not to be found in the Yeoman boilerplate, so it looks like it is initialized by the framework these days …

I want to find out where this happened in the Yeoman boilerplate. As far as I can tell the documentation is not all too clear about this.

To be continued too Winking smile

Office Development – Where to Start

Office Development – Where to Start

clip_image002

Starting at dev.office.com you see a wide variety of options related to Office Development. There are a couple of sections to identify when you enter the Getting Started entry

  • Microsoft Graph
  • SharePoint Add-ins
  • Office Add-ins
  • Office 365 Connectors

Apparently, this is not all, as below the four options there is another option:

Can’t find what you’re looking for? Check out this full list of all development options for Office linking to the URL https://msdn.microsoft.com/en-us/office. If you follow this URL you’ll notice that it is redirected to, you might have guessed it: https://dev.office.com/docs, the documentation part of dev.office.com.

Here the options are not limited to the options above but now you can see there are sections for:

  • Microsoft Graph
  • Office Add-ins
  • Office 365 Connectors

And below this

  • Office Clients
  • Outlook.com
  • OneNote
  • SharePoint
  • OneDrive
  • Yammer
  • Exchange
  • Skype

Wait …, what …, why is there a section Office Clients separated from the Office Add-ins?

Well, I don’t know. Looking at this it you might think the ‘older technologies’ are under the ‘subsections’. This is true for Office Clients, covering:

  • Office 2013
  • Office 2010
  • Visual Basic Reference

The last item in the list is in fact incorrect, and should have been called “Visual Basic for Applications Reference” or “VBA Reference” or even better “Language Reference VBA” as it redirects to Language reference VBA. It has nothing to do with Visual Basic. Sure Visual Basic resembles a lot compared to Visual Basic for Applications (I will reference to VBA from now on for Visual Basic for Applications) but it isn’t the same. It’s as if you compare Visual Basic to VB.NET they aren’t the same either.

To continue the ‘older technologies’ theory … under SharePoint you find:

  • SharePoint Framework
  • SharePoint WebHooks
  • SharePoint Add-ins
  • SharePoint 2013
  • SharePoint 2010

In this case you see a combination of older and newer technologies. Also under the other subsections you find a mix of newer and older technologies (Exchange) or just newer technologies (Outlook.com, OneDrive, Skype, OneNote and Yammer).

There are even parts missing on this part of the documentation. What about Microsoft Teams as a newer application of Office or existing applications like Microsoft Access. Office and therefor Office Development is just huge, we can spend so much time on these sections, there is no end in all of this.

To start the research, I first want to focus on the Office Clients and their Add-ins. The reason for this is that this was the part that was applied the most when you look at Office customization (adjusting the Office client applications in a way that it suited the needs of the productivity workers).

So, I will drill down from the part covered under Office Clients and move over from there to the section Office Add-ins. This will provide a sense of history and slowly move into the newer technologies as provided in the OfficeJS APIs.

Enough stuff to dig in, so hang in there … see you in my next blogpost(s)