Office Development–How to reach the Office Extensibility Platform team

StackOverflow

A long time ago, I answered a lot of questions in the so called Microsoft Forums assisting the community with VSTO issues. The forums still exist (https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vsto), but are not the main access point anymore if you want to reach the Office Extensibility Platform team with your questions or issues.

These days https://www.stackoverflow.com is the center of the Universe (well… not really but if you have developer related questions it is … sort of …).

StackOverflow is a huge knowledge base of information formed out of an even bigger stack of questions from the community answered by not only the community but also from many of the ‘real’ product groups. If you are building your Add-ins using OfficeJS your can go to:

https://stackoverflow.com/questions/tagged/office-js

This “office-js” tagged group of questions is actively monitored by the Office Extensibility Platform team and you might recognize many of the team members as being the ones answering your questions (or apologizing if you reached an issue). By asking your questions in there the information around it is automatically functioning as future reference item.

You’ll notice, if you Google for a specific issue or question, that you’ll hit StackOverflow simply because you often won’t be the only one with that question. Big chance that the answer is already available and that will save you the time to submit the question.

Remember, that by submitting your question, you are not only helping yourself but you’ll help many others arriving at a later time with the same question.

And … while you are at it, try to answer some of the open questions if you know the answer. It will provide you ‘reputation’ points that may help you even more. The more reputation points you get the more you are ‘credited’ with features. If your reputation is high enough you’ll be able to moderate questions with a group of peer moderators, and if it is really high you can moderate without confirmation of other moderators. You basically build trust by doing good.

BTW, the office-js tag is not the only tag where the team lives, other examples and my favorite tags:

image

Note that VSTO is also in there:
https://stackoverflow.com/questions/tagged/vsto
so if you have questions on the good old VSTO tools this is your go to place Winking smile

Office Development – Minimal Code in practice

MinimalCode

Returning on my last ‘minimal code’ blog post, I promised to get back on this to see how this works in practice. One of my question marks I added to the post was that I wondered why the Yeoman boilerplate was using run instead of RequestContext where run passed a context parameter as opposed to the RequestContext where actively a context is requested before accessing the Word object model.

I think I found an answer to that, but will save this to a later date as I first want to make sure the minimal code I provided would work and I found some issues in the original posted code that didn’t seem to be correct.

Here is the updated code that should work in real life:

(() => {

   async 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();

      range.insertText("Test MinimalWordMethod", "After");

      await ctx.sync();

   }

   MinimalWordmethod();

})();

How to get the minimal code running

If you go back to the Yeoman project instructions in this post (and fixed the certificate issues in post Office Development – Fixing Trusted Authority – Word Client and https://maartenvanstam.wordpress.com/2017/08/07/office-development-fixing-certificate-issue-with-openssl-certificate/) you should already have a working Word Add-in.

Open the project folder (or if you already deleted it quickly create a new one following my instructions from my earlier blogposts) and open the file app.ts in the src source folder.

Replace all the code from this file with the code above, save it and start your Add-in ‘server’ by running npm start in the root of your project.

Opening Word, with the installed Add-in (again, if you already dropped it follow my other blogposts earlier this month to install it) will show you the Add-in button:

addin7

By clicking the button the Taskpane is showing, just like we’ve seen before as we haven’t changed the Taskpane ‘web’ code, but now you should see the words “Test MinimalWordMethod” arriving in your document:

MinimalCode2

As you can see the code worked! Here is how:

MinimalWordmethod();

This line is automatically triggered when the code is running on startup of the Add-in. By doing so inside the MinimalWordmethod a context is requested in this line:

var ctx = new Word.RequestContext();

If the context is returned correctly you now can access the Word object model to access parts of the document. In this case we access the selected Range object and insert the text right after the Range:

var range = ctx.document.getSelection();
range.insertText("Test MinimalWordMethod", "After");

Instead of having this executed immediately like we’ve seen in VBA or VSTO, the text is only inserted after calling the sync method on the context. In the JavaScript APIs for Office calls to Office are handled asynchronously and to work with that the await and async keywords can be found in the code.

Very simple and basic code, but there are some drawbacks you need to keep in mind. For instance, because things are async, how do you know what the right order is how things are processed. And what about batch processing of boatloads of instructions? Will this all be handled correctly, and what if there are dependencies between the batched instructions? All of these questions arise when looking at this little piece of code, and we need to address all of that in later posts.

To be continued … It’s a never ending story Smile

Office Development – Add-in Types, what did we have before?

Office-Development-VSTO_thumb.png

To research the ‘new’ Office JS Add-ins we need to know what types of add-ins there are. If you come from VSTO there is some similarity, add-ins can be divided in different types. Let’s see what we had before.

In VSTO you had the option to create Document Customizations aka Document-level customizations where the add-in was attached to the document or spreadsheet, Application-level customizations, here the add-in lives in the context of the host application like Word or Excel and Outlook Form Regions for customizations in Outlook

Project Type Feature Application
Document Level Customization Actions Pane Word

Excel

Custom Ribbon UI Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

Backstage View Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

Controls on Documents Excel

Word

Shortcut Menus Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

Application Level Customization Custom Task Pane Excel

InfoPath

Outlook

PowerPoint

Word

Custom Ribbon UI Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

Backstage View Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

Outlook Form Regions Outlook
Controls on Documents Excel

Word

Shortcut Menus Excel

InfoPath

Outlook

PowerPoint

Project

Word

Visio

So, in general there are these options explained a bit:

  • Actions Pane/Task Pane (Depending Application or Document Level)

    This is the pane on the right of a document that allows you to interact with the document. In case of an Actions Pane this is attached to the document, while the Task Pane can be there independent of the document. They can both do arbitrary things, but the Actions Pane only appears with the document.

  • Ribbon UI adjustments

    Adding your own Ribbon with controls on it. VSTO can add almost every Ribbon Control available.

  • Backstage View

    Backstage View is the view that you see when you select the File Tab. This allows you to add a special tab in there for whatever you want to show there. Some limitations apply

  • Outlook Form Regions

    Outlook Form Regions extend the way you work with your mail. There are options to just add a small part on top of the mail item or take over the full real estate. You can specify when this happens, will it be only in compose or read mode? You decide.

  • Controls on Documents

    With this feature you can enhance the document with extra controls on top of the document surface. The controls are not always persistent and you may need to re-create the controls each time you open the document if you want them to appear again.

  • Shortcut Menus

    These are the context menus. Right click on the document and add extra function call options within the right-click-menu to allow the user to do specific tasks related to the position of the caret (insertion point where the cursor resides).

This is quite a lot of functionality and also keep in mind that from most of these features you can do the craziest things because you can extend the Task Panes/Action Panes with either Windows Forms but also XAML interfaces. The other features can use the full .NET Framework stack so you can do everything you want.

The challenge is now to see if we can get the same things with Office JS Add-ins. Obviously you don’t want to fall back into a limited feature set. On the other hand, there is the fact that it needs to run on multiple platforms. That can be a limiting factor.

Given this summary I now have a goal to what to look for in the ‘new’ world.

To be continued …

Office Development–The Good

Office Development - Good

So after a small introduction to the “Ugly” VBA, the “Bad” VSTO, we end with the “Good” … well end … I guess the end is just the start of a new experience of an Office Development platform not familiar to most people. It is not included in the box like VBA, not using the languages most Microsoft developers are familiar with.

So what is it? Office Add-ins, yes … this time with the capital A, indicating that we discuss the –new- way of developing Office customizations, are built using well known web development technologies like HTML, CSS and JavaScript.

By doing so Office Add-ins run across multiple versions of Office:

  • Office for Windows Desktop
  • Office Online
  • Office for the Mac
  • Office for the iPad

This is most likely not all, with Office emerging on other platforms like Android and Linux distributions these options will be on the shortlist as well. We will research these options on a later time.

So how does this work?

The architecture is a little bit different than the other technologies, although you can debate that the Office Add-ins mechanism looks like the way it was done with VSTO.

This is how it looks like with the JavaScript Office Add-ins:

DK2_AgaveOverview01

There is an Add-in manifest in the XML format and a web solution hosted on an arbitrary web server. The image shows HTML + JavaScript but it can be more than that as long as valid web technologies are in place. The manifest contains all sorts of settings (we’ll dive in to see what is in there also later on) and it defines what Office clients are used and what it needs to run.

The Office JavaScript API first implemented some basic Excel features and even less Word features but today many more clients are supported and the Excel and Word features are getting more mature over time. The JavaScript API for Office contains objects and members that you need to build your add-ins and interact with content in your Office documents and web services.

If you look at the API you will see that you recognize a lot of your ‘old’ Office Object Model. Some are close to what they were, others needed to be adjusted and there are also new options.

Ok, the starter is here … in my next posts I will pick each of the items and look at the details. As I said earlier, this for me is probably like you a learning experience. I’ve been looking at it for years now in a helicopter/management overview but I decided I need to learn the ins and outs of the new platform. While doing so I try to teach you as well by blogging about it. Trying to keep it simple and getting more complex over time.

Let’s see if Office Add-ins are really the “Good” as advertised and can they do the same as we can do with VSTO add-ins….

Office Development–The Bad

clip_image002

Visual Studio Tools for Office (VSTO) is a set of development tools available in the form of a Visual Studio add-in (project templates) and a runtime that allows Microsoft Office 2003 and later versions of Office applications to host the .NET Framework Common Language Runtime (CLR) to expose their functionality via .NET.

Quote: https://en.wikipedia.org/wiki/Visual_Studio_Tools_for_Office

As we have seen in my previous blog post Office Development – The Ugly the first option to build your Office extensions using Visual Basic for Applications (VBA) did not win the beauty contest. A very powerful toolset to create beautiful and especially productive customizations. I’m sure that VBA, the tools to set Office to your hand, allowing you to tailor Office in a way that it perfectly fits the needs of your company, is one of the main reasons that made Office such a popular box of applications.

It was however risky – a potential security risk and code management is a pain. In the real world it happened that a ‘new’ version was rolled into production where all the sudden existing features ‘disappeared’ as a result of the developer picking the ‘wrong file’ containing an older version of the solution and continued developing features using the incomplete version.

This needed to change … in the meantime managed code -.NET- appeared at the horizon and the next option at least had to be a) secure and b) needed an improved source control option.

The solution Microsoft put on the table were the:

Microsoft Visual Studio Tools for the Microsoft Office System.

The product name was most likely the longest name available at that time. The Visual Studio Tools for the Microsoft Office System (VSTO) was architected as a bridge between Visual Studio and The Microsoft Office System. On one side the languages team with Visual Studio, on the other side the Office team and in the middle the VSTO team – code named Trinity …

clip_image004

So how is VSTO different compared to VBA?

Applications, add-ins or document customizations, are built using Visual Studio. Initially in a separate Visual Studio .NET 2003 VSTO SKU and after a few version inserted in the Visual Studio 2008 box. The code no longer lived in the documents or other Office files, but from now on lived in an external assembly that would be triggered by the Office host application if the right properties were available in the document.

Loading the assembly was done in a relative complex manner and it was made sure that security wise the pain seen with VBA would not exist with VSTO add-ins.

Here is a schematic overview of the load pattern:

clip_image005

As you can see the Office Application is looking at the Registry to see what add-ins are installed, if found any the Deployment manifest (pointed to by the Registry) is read and following that the Application manifest is read and the assembly loaded.

A real extension to the Office Application … to make this all secure the security is enforced at installation time. There was a whole slew of prereqs that must be covered before the add-in would be installed:

clip_image006

This part made VSTO the “Bad” in The Good, The Bad and The Ugly … it appeared to be a real pain for the IT Pros at the time. By default, VSTO used Click-Once to install the extension on the machine and a lot went wrong … certificates expired, not added to the Trusted Publisher lists, etc. etc. There was another option, to install an add-in using an .msi installer but the average VBA developer had a hard time getting around all of this, jumping all the hoops to make it work.

Was it all Bad?

Not at all! By using managed code, C# or VB.NET – whatever your preference was, your world of Office completely opened. Whatever you could do with .NET (and that is basically everything) you could add to your solution. Calling third party libraries, UI components, later even XAML UI interfaces, sky is the limit.

For me personally this is still my fav option to build Office customizations. I wasn’t awarded nine-year Visual Studio Tools for the Microsoft Office System MVP – I guess the longest MVP title as well, without reason. VSTO controlled my life for the large part of these years (hopefully my wife is not reading this ) did a lot of forum support in this area and built VSTO applications for large enterprise companies. At the time, we still had on Microsoft campus Software Design Review meetings to share feedback and we gave the team a hard time to make sure they released the features that we really needed.

Where to go next

But … the world changed, Windows is no longer the only platform that needs to be supported. Because of that a new mechanism was proposed. By using the common web standards and JavaScript a platform independent system was developed by providing OfficeJS APIs to access the Office object model from web based add-ins.

And this is where we will dive in soon. It’s a relative new world, although development already started years ago, so there is a lot to learn there. Let’s see if we can do the same with OfficeJS as we can do with VSTO – but now on multiple platforms and several clients.

Maybe I will return to VBA and VSTO in separate blog posts just for fun. There is just a ton of information to share on all off these areas.

Book

Oh, and if you really want to know the ins and outs of VSTO I really recommend you reading the VSTO bibles by Eric Carter and Eric Lippert: Visual Studio Tools for Office 2007: VSTO for Excel, Word and Outlook. It is a huge and heavy piece of reference with over a thousand pages of inside information.

Office Development–The Good, The Bad and The Ugly?

Office Development - Good Bad Ugly

In my last post we’ve seen that there are just a whole list of options covered under Office Development. Just to get a starting point we start to focus on Office add-ins –without the capital A– first. With Office add-ins I mean Office add-ins in general, that is … from the early start to where we are today.

I know that these days the name Office Add-ins is considered to be the part where Office Add-ins are built using the OfficeJS APIs but in the early years you had Office add-ins in many forms and technologies.

The Ugly

Initially the only option to customize Office was by adding code using Microsoft’s Visual Basic for Applications (VBA). This was, or should I say is – it still exists and you can still use it, the embedded code engine running a subset of the full Visual Basic command set capable in addressing the Office Object Model to quickly build some Office automation functions to make life as an Office Worker easier. The language appeared to be very powerful and in the real world people built some crazy complex stuff with it.

The Bad

To add more structure to building Office add-ins a new development paradigm was developed. Still using the Office Object Model but this time using the managed languages such as VB.NET or C Sharp (C#).

Managing code with VBA could be a pain in the … Code traveled with the documents and when the document was copied another ‘branch’ was created and you would never know you were working on the latest version unless you managed your distributions very strictly. Also the declaration of variables wasn’t always enforced causing all sorts of runtime errors to surface just after releasing the production code.

By using this new way to build your Office add-ins or customizations (I will return on customizations vs. add-ins later in a separate blog post, that’s a story on itself) with the new tools: Microsoft’s “Visual Studio Tools for the Microsoft Office System” (VSTO) at least you had a better control over your source code and you could even use Source Control to keep track of your code versions.

With this, the first versions of VSTO, seemed to be very hard when it came to installing the add-ins. Security was improved a lot, but that came at the high price of tough installation issues.

The Good

In these days, deploying add-ins can’t be limited to the Windows Platform so another change was rising … these are the add-ins built using the combination of well known web technologies and by including a Manifest you are now able to run your Office Add-ins (with the capital A) on all platforms in all supported and still growing number of client applications. Currently the client applications are Excel, Outlook, PowerPoint, Word and recently added Project, Access and OneNote.

Really?

Are these three technologies really The Good, The Bad and The Ugly? Well no, obviously not, you can still build add-ins in all three of these technologies but VBA for instance always had a very bad name, also caused by virus developers using this technology to harm innocent computer users by exploiting the technology to take over the computer and in worst case disable it.

VSTO was considered to be a real improvement but this technology also had his downsides. Deployment could be really hard, but this improved in later versions. Still going multi platform was no option for VSTO.

So is all good with the OfficeJS add-ins? Again, not at all … for starters these technologies used here are in general very hard to understand when you come from the VBA or managed code languages. Also, the APIs are not fully completed.

It still isn’t possible to do all the things that you could do with VSTO. With VSTO there is not really a limit. Whatever you can do with managed code you can do with VSTO as it just is interfacing between Office and .NET. This of course in itself could be very dangerous and should be managed to the max. Also VSTO is used by shady guys building malicious code.

We will get more in detail (we are still diving in, going deeper and deeper at this time) in my following blog posts so subscribe and join me in this adventure called Office Development!

Office Development 2017

Office Dev Center

After many years of Office Development, starting with Excel Functions, VBA, COM (VSTA/VSTO) it is time to dive in and see how things are in done in 2017. What are your options, is it still possible to do things in VBA or doesn’t it exist anymore?

In my upcoming blog posts I want to look at the options available and look at the Office Platform in general. What clients are there these days and on what platform do they run.

The world changed a lot in the last decade and Microsoft Windows is not the only platform anymore. There is iOS, Android, MacOS, Windows … even Linux distributions are growing in popularity.

Even if you just look at it in the online (web) world many of the ‘old’ clients are now available in an Online version. Think of Word Online or Excel Online where you get your editor or spreadsheet application running in a browser application. Again, not so easy as you might think … browser applications should be running in a wide variety of browsers. Do they run in Internet Explorer, Chrome, Safari, Opera etc. etc.

My goal with these Office Development blogposts is also maybe a bit selfish … coming from the ‘old’ (as you might discover) VSTO world, or even older VBA world, I need to polish my knowledge around the current options available and I can already tell you that this ‘new’ Office Development world is huge compared to what it was as the number of clients increased dramatically with the operating systems that I mentioned above, but there is also a huge amount of mobile applications for Android, iOS and (currently not so many for) Windows Mobile.

So … a big challenge. I have no idea where this ends because Office Development these days also include developing for Microsoft Graph (it was Office Graph before, but it was revamped into Microsoft Graph this year, growing bigger than it already was), SharePoint Framework or Office Connectors to extend your Groups or Teams.

That said, stay tuned and feel free to share your comments, tips or complaints in the comments section below!

For now, your starting point for Office Development (next to my blog off course) is:

https://dev.office.com/  

Back to Blogs … Installing Live Writer 2012

I lost my blogging tools in the process of testing Windows 10 and or reinstalling machines. I now finally came to install Live Writer back on my machine.

I am working on getting my way around Office365 Development. It appears that developing using VBA and VSTO Add-ins is soooo year 2000, time to move forward Winking smile.

Well, the real story is that in my day job I’m still on VSTO but it probably doesn’t come as a surprise if I say that Microsoft already spent at least four years (plus) by now on creating a new Add-in platform that is ready to target X-Platform (Windows, IOS, Android) development.

They still have a long way to go, many items within the current (COM) object model still needs to be addressed, but as time is moving forward the Office Development Team is making great progress in adding new features every day hopefully in the end getting in par with the VSTO capabilities. And let’s be real, the Office365 scope of today is so much bigger than the scope of the ‘old’ Office.

Anyway, I got rebooted, and if you can read this I was able to get Live Writer 2012 installed and to be ready for future posts.

Oh, and this is how I installed Live Writer – in case you want to join me and start your own blog:

[Thanks to Stefan to help out here: http://blogs.technet.com/b/stefan_stranger/archive/2015/07/24/installing-windows-live-writer-on-windows-10.aspx]

VSTO Runtime Update (10.0.50325)

The Visual Studio Developer Division just announced a new version of the VSTO (Visual Studio Tools for the Office System) Runtime (10.0.50325).

One of the issues, the one when using WPF controls caused a massive delay in closing Office applications, I worked close with the team to test and get this solved. The issue also reported on Connect was a hard one to fix as it depended on many factors such as Touch Screen interfaces and appeared on previous versions of the Runtime.

The second issue addressed by this update covers the publisher’s name and verification status to show properly when using SHA256 code-signing certificates where the Trust Prompt at first displayed “Unknown Publisher” even when the publisher was fully trusted.

Read more about the Runtime Update at the blog from the VSTOTeam located at:
VSTO Runtime Update to Address Slow Shutdown and “Unknown Publisher” for SHA256 Certificates 

You can download the latest version of the VSTO Runtime at http://go.microsoft.com/fwlink/?LinkId=140384 and will be distributed as part of Windows Update.

I for one am very happy to see this solved and released to the public. Our enterprise firm encountered the WPF issue on a large scale just after deploying our top of the bill new laptops to all of our users and would like to thank the VSTO Team for working with us to get this out of the way! We really spent a huge amount of hours in this to cover all the scenarios we could think of in both new and older (existing) add-ins.

Showtime: The Book Thief

The Book Thief


The “Showtime” section on my blog is a reminder, mostly for my own reference but maybe helpful for other film enthusiasts as well, to remember what movies I’ve seen lately, what it was about and how I rated it in general.


The Book Thief is about a little girl, unable to read and write at her early years to be abandoned by her mother in times of war in the 1930’s. While living at her foster parents home she learns to read and write and especially gets the affection to read books. To be able to read books she steals (or borrows) the books and was called “The Book Thief” by one of her neighbor boys.

the perspective of a German family in war time isn’t used in many films. Especially a family giving shelter to a Jewish refugee in a city of Germany is a less common thing to project.

The movie is highly (maybe over-)dramatized, displaying some intense situations people had to go through when the world was at war. Although the level of dramatization could be a bit less overall it is a touching story. The girl playing Liesel Meminger (Sophie Nélisse) is a rising star and I think we haven’t seen the last of her yet.

I expected the movie, given the amount of nominations, to be somewhat better and rate it a high six out of ten.

New Office REST APIs and Developer Tools for Visual Studio Update

Tonight (here in Europe that is) Somasegar announced on his blog that the Visual Studio Team and the Office Team released a “number of significant updates for developers building apps that interact with the Office ecosystem”.

All of the updates are more or less related to building Apps for Office/SharePoint and the Cloud. If you need full integration (interacting between Word and Excel, building compound documents, Ribbon interaction etc.) I think you still need to use the ‘other’ option, VSTO. The downside of –that- however is that it won’t be as mobile a you’d like to see. You win some or lose some, depending on the technology you decide to use.

Back to the updates… Announced today were the new Office 365 APIs for consuming Office data and updates of Office Developer Tools for Visual Studio (not to be confused with Visual Studio Tools for the Office System aka VSTO, that is a complete other thing) and “Napa”.

Go and read the blogs for details on all of this,  no need for me to repeat all of it Glimlach

  • The Office 365 Platform blog
  • The Visual Studio blog
  • This year I’ll try to deep dive on this a bit more to get into the subject of replacing your current Add-ins with Apps for Office/SharePoint – Can you or can’t you? Where are we at the moment. Everyone wants to move their Add-ins into the Cloud, but is it even possible today? More on this later …

Showtime: Philomena

Philomena


The “Showtime” section on my blog is a reminder, mostly for my own reference but maybe helpful for other film enthusiasts as well, to remember what movies I’ve seen lately, what it was about and how I rated it in general.


Philomena is a movie nominated for 4 Oscars and a whole slew of other rewards. You wouldn’t expect that by just watching the trailer of the movie.

The movie is about a woman who got pregnant at a very young age and therefor was put away in a Catholic convent where her son was born. Shortly after that her son was taken away from her for adoption.

Journalist Martin Sixsmith started to follow Philomena’s story and together with Philomena he started their search for her long lost son who appeared to have been adopted by an American family. On the search they travel to the United States where they tried to find his current location.

The story of a mother searching for her son changed from a series of facts into an emotional piece of art where spectators in the audience had a hard time to keep it dry. In a silent moment you could hear a soft crying from all directions. The producer managed to touch the hearts of many with this drama. Nine out of Ten, highly recommended !