Office Development – Word Add-in in Visual Studio ‘in action’

Yesterday in my blogpost I showed you the instructions to perform to create your first Word Add-in not by command line tools like I showed earlier, but by using Visual Studio 2017. So here it is:

Boot up your Visual Studio IDE and select File, new Project. In the New Project Dialog select on the left hand of the dialog the tree item Add-ins under the Office/SharePoint node. On the right hand you get options to build Add-ins for Excel, Word, Outlook, PowerPoint and SharePoint.

 FirstVSAddin01

They still call it Web Add-in, if you ask me this name is a bit outdated. I believe the Add-ins are called just Office Add-ins (with the capital A). There was a time these things were called “Apps for Office”. The name used today on the http://dev.office.com website is:

Apps for Office

Where were we? …. Oh, yes … Creating a new project. Name your new project any name you would like to give it, I opted for MyFirstWordAddin. Change the folder if you want to store it somewhere else other than the default project output path and click OK to start creating your project. If all goes well you’ll see the following ‘progress’ bar appearing on your screen.

FirstVSAddin02

It takes a couple of minutes to finish, but when it does it will open a code window like this:

FirstVSAddin03

And another tab was created to show you some helpful links to continue:

FirstVSAddin04

Now it is time to hit F5, the “Visual Studio Compile-Run-Debug Experience”. As we have seen ancient times ago the Office Dev team really tried to hide all the difficult stuff for you and it will create for you the security context to be able to actually run the Word Add-in without going through the hassle I described in other posts creating the Add-in using the command line tools like Yeomen.

The only dialog might get to see in between is this one:

Cert1

A one time only trust entry for your self-signed Localhost certificate. You’ll notice if you create a second project this dialog won’t show again as you already trusted it for your first project. Click Yes otherwise your Add-in won’t be trusted to run. It will create the security context and an instance of Word is created and installed the just created Add-in.

On the top right hand in the Ribbon in the Home Tab a button appears in the Commands Group with some easy instructions. You’ve seen as similar button and instructions on the command line Add-in we created a while ago.

FirstVSAddin05

Click the button to have the Task pane appearing on the right hand. The sample Task pane wants you to select a couple of words in the document and if you press the Highlight button it will calculate the word with the most characters and highlights the word.

FirstVSAddin06

That is all there is to it … no fancy pansy difficult stuff to get around creating certificates and trusting the certificates. It is all done for you by the Visual Studio tooling. Impressive!

Beware however, you are not ready for production – just like the command line Add-in tools, the certificate is self signed, you are not running the ‘ web app’ in a shared (public) location to be able to access from anywhere and anytime. It is still ‘demo-ware’. Hopefully over time we will reach the golden moment of creating ‘production-ware’ Smile

To be continued …

 

 

 

Office Development – Word Add-in – Using Visual Studio

Office Development - Visual Studio

A while ago, not too long, I showed you how to start developing your Word Add-in from scratch using nothing but command line tools. Check my blog archives for the last couple of weeks if you missed that. Today we are looking at the same process but now using Visual Studio.

Where to begin? According to the page: https://dev.office.com/getting-started/addins going through the process of steps you select Word as Add-in host, and Visual Studio as tools to build your Add-in will finally show you the following screen:

image

It is already hopelessly outdated, mentioning to install the Office Developer Tools for Visual Studio 2013 or 2015 while Visual Studio 2017 has been around for quite some time.

The process however is still unchanged for the most part, I will show it in practice in a later blog, but if you follow the three steps you are basically already there, where without Visual Studio and just using the command line tools we had to go through a large series of requirements and certificate fixes to make that work.

Apparently Visual Studio takes a lot of this out of your hands and is doing all that for you. Not completely fair, because with Visual Studio you also need to go through the installation process. I want to find out what this all is and put that in a blog post as well

To be continued …

Windows 10 Insider Preview Build 16275

RS3 Windows 10 Insider Preview 16275

Apparently there was some need to push another build out today:
https://blogs.windows.com/windowsexperience/2017/08/25/announcing-windows-10-insider-preview-build-16275-pc-build-15245-mobile

Only two days ago in my blogpost I discussed the update 16273 for both Redstone 3 as Redstone 4 where I mentioned that the Redstone 3 (Fall Creators Update) would show us just some stabilizing and bug fix items. And this appears to be right, this release, Build 16275, has just been pushed out to the Fast Ring of the Fall Creators Update and not to the Skip Ahead (Redstone 4) flight.

Also Build 15245 for Mobile was released, but you might wonder what the use of this is where the number of Mobile devices is shrinking each day without the option to buy new devices. They are simply unavailable in stores, even in Microsoft Stores they are no longer available.

SDN Cast 64 – Live at 8 with C# 8 and Android 8

clip_image002

Lucky 8, this week is themed number 8 … We are broadcasting the Dutch SDN Cast 8 squared = 64, Mads Torgersen was interviewed by Seth Juarez on C# 8 discussing features like Nullable Reference Types, Async Streams, Default Interface Implementations and Extension Everything. C# 8 is still in the planning phase but as with previous releases Mads shares the things the C# team are thinking about to put in the next release. Features obviously may be dropped or can be changed for the final release but the recording shares a lot of new stuff with the public already.

Also, Android 8 aka Android Oreo was released this week. Another 8 for us to consume. The Dutch Android site is still on Android Nougat but setting the locale to United States changes the site to Oreo.

Another big thing this week is Gamescom, where Microsoft opened the pre-order for Xbox X aka Xbox Project Scorpio. With this Xbox is opened for any games developer. Xbox used to be closed for development unless you were one of the certified game developers. This restriction is now lifted and only thing you need is a Dev Center account that you can purchase for $20 one-time fee.

Another demo this week, this time Skype integration on your website with two lines of code. How to easily put Skype interaction on your site, to living persons or even bots.

Where can you find our 64th episode of our Dutch SDN Cast?
https://youtu.be/5FkP9AuuZmY

Did you subscribe our Dutch SDN Cast channel already?

Subscribe your YouTube channel if you don’t want to miss a single broadcast. Usually we will broadcast on Thursday evenings at 8 PM but there can be a change of plans where we need to move to another time or day. So to be sure Subscribe to our channel on YouTube or go to http://www.sdncast.nl to see when the next episode is due.

Other news:

A Preview of C# 8 with Mads Torgersen
https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8-with-Mads-Torgersen

· [05:37] – Nullable reference types

· [16:30] – Async Streams

· [26:13] – Default Interface Implementations

· [32:11] – Extension Everything

Angular v4 TypeScript Snippets
https://marketplace.visualstudio.com/items?itemName=johnpapa.Angular2

Git vulnerability with submodules
https://blogs.msdn.microsoft.com/devops/2017/08/15/git-vulnerability-with-submodules

Android 8.0 Oreo
https://www.android.com/versions/oreo-8-0/

Apple: New Beta Downloads Now Available, Beta 7
https://developer.apple.com/news/?id=08212017a

CodeRush 17.1.7 Released
https://community.devexpress.com/blogs/markmiller/archive/2017/08/22/coderush-17-1-7-released.aspx

Rider 2017.1.1 is released
https://blog.jetbrains.com/dotnet/2017/08/22/rider-2017-1-1-released

Taking feedback
https://blogs.msdn.microsoft.com/bharry/2017/08/18/taking-feedback/

Events

Events this Week

Gamescom
http://www.gamescom-cologne.com/gamescom/index-9.php
https://mixer.com/Xbox

https://www.microsoft.com/nl-nl/store/d/1-tb-xbox-one-x-console-project-scorpio-editie/8zjh508rnql0/xk0g

MvvmCross .NET Summer Hackfest, August 21st to September 2nd, 2017
https://www.mvvmcross.com/hackfest/

Upcoming events

Google Developer Days Europe – September 5-6, Krakow, Poland
https://developers.google.com/events/gdd-europe/

Wazug – September 7 2017, Hilversum
https://www.wazug.nl/Event/Details/2059

Microsoft Edge Web Summit 2017 – September 13, Online
https://summit.microsoftedge.com/

MixUG – Development Event – 13 September, Gouda
https://www.eventbrite.nl/e/tickets-mixug-development-evenement-34890959800

Xamarin Dev Days – 16 September – Amsterdam
https://ti.to/xamarin/dev-days-amsterdam-2017

DevIntersection Europe, September 18-20 – Stockholm
https://www.devintersectioneurope.com/#!

.NET Conf – 19-21 September
http://www.dotnetconf.net/

Microsoft Envision – September 25-27 – Orlando
https://www.microsoft.com/en-us/envision/default.aspx

Ignite 2017 – September 25-29 – Orlando
https://ignite.microsoft.com
https://myignite.microsoft.com/sessions

Hybrid IT Event – September 26 – Maarssen, NL
http://www.fujitsu.com/nl/microsites/hybrid-it/event/index.html

4DotNet Events – Xamarin Event – 28 september, Nieuwegein
https://events.4dotnet.nl/xamarin-event

MixUG – Eindgebruikers Evenement
https://www.eventbrite.nl/e/tickets-mixug-eindgebruikers-evenement-34890983872

SDN Event 3 – 6 October 6, Zeist, NL
https://www.sdn.nl/EVENTS/6-oktober-2017

TechDays October 12-13, 2017 RAI Amsterdam 
http://www.techdays.nl/
https://techdays.msnlevents.net/content/eventselection.aspx?eventid=26152

SharePoint Saturday Belgium 2017, October 21, Brussels BE
http://www.spsevents.org/city/brussels/brussels2017

SharePoint Unite – October 24-26, 2017, Haarlem
https://sharepointunite.com/

Dev Intersection, October 30- November 2, Las Vegas
https://www.devintersection.com/#!/

Web Summit – 6-9 November 2017, Lisbon, Portugal
https://websummit.com/

Visual Studio Live! November 12-17 2017 Orlando, FL
https://live360events.com/events/orlando-2017/vslive.aspx

As usual we are always looking for presenters for our own events and Meetup’s so if you want to share something about hot technologies or just about something you implemented at work or in an App that could be interesting to our audience let us know so we can schedule you for one or our next SDN events or Dutch .NET Group Meetups.

This off course also goes for if you want to write a great article for us to publish in our SDN Magazines or at our SDN Website. The downside of publishing a magazine article is that there can be sometime between writing the article and publishing the magazine. So, if it is time critical sometimes the best option is to publish it on the www.sdn.nl website to get more speedy attention to the article.

As you see, options enough to address your audience with top notch information. You can even, if you like, be our guest in our SDN Cast shows to discuss the projects you are working on or other topics you master. We will instruct you how to connect with us and what it is you need to join the show.

Hopefully we will see you at our weekly web cast, for the schedule go to www.sdncast.nl for next week’s announcement to find out the day and time of our next broadcast or go to www.sdncast.nl/youtube to watch old episodes and videos that we recorded at our events. Don’t forget to subscribe our YouTube channel www.sdncast.nl/subscribe or go directly to YouTube not to miss any of our shows!

Redstone 4 – Windows 10 Insider Preview 16273.1000

RS4 Windows 10 Insider Preview 16273.1000

A little while ago I mentioned there was no jumping on the Redstone 4 (Windows vNext after Windows 10 Fall Creators Update) train anymore if you are not already on that train.

Today there was an update for the ones who -are- riding the RS4 train: Windows 10 Insider Preview 16273.1000 (rs_prerelease).

Notice the tagged “rs_prerelease”, this indicates you are on the Redstone 4 track. The ‘commons’ on Windows 10 Insider Preview will have the tag “rs3_release”, also released today.

image

No clues to what has been fixed in these releases, it has been about 3 weeks since the last update due to some bugs found so I’ll just assume that it is just more stabilizing Redstone 3 stuff.

Go get it if you are an Insider! 

Update: Here are the change notes for this build at the Microsoft Windows Blog https://blogs.windows.com/windowsexperience/2017/08/23/announcing-windows-10-insider-preview-build-16273-pc

Announcement – Crashplan Home Discontinued

Crashplan

Code 42 just announced that they will discontinue their Crashplan Home services:

https://www.crashplan.com/en-us/consumer/nextsteps/

Darn … I was using this service for several years now and was quite happy with the silent, off premise backup for all of my machines for a fairly low annual fee. Now I have to go out again and find another service comparable to this one Sad smile.

One of the benefits was that you could run a headless backup from your Synology servers and I’m not sure there are others doing the same thing. Code 42 is going to focus on business users only:

https://blog.code42.com/data-protection-needs-diverge/

Maybe, I need to look into it, I just move over to the small business option if the options and the price is right. One thing is certain … I will lose some time on this to research what to do next for backup …. oh well …

Office Development – Book: Building Office Add-ins using Office.js

clip_image002

While looking for references and/or resources to support my research on the ‘new’ Office Add-ins I repeatedly stumbled over the sample chapters of one book in particular:

Building Office Add-ins using Office.js

https://leanpub.com/buildingofficeaddins

The book is published on LeanPub and this means that it is work in progress. The author is continuously working on the manuscript and is potentially never finished. Even the pricing is flexible, the author specified a minimum and a recommended fee. You can decide if you want to pay the minimum, recommended or even a higher amount for the book. At this time, the minimum is set to $15.99 and the suggested price is set to $19.99 but as said you can up the price to $500 if you like Smile

clip_image004

You don’t have to worry the information provided is legit, the book is written by Michael Zlatkovsky who works at the Office Extensibility Platform team at Microsoft. The information is therefor right from the source, even better … Michael has been a key participant in the design of the new Office 2016 wave of Office.js APIs:

https://leanpub.com/u/Zlatkovsky

Michael and I go back quite some time already, I met Michael years ago, I thinks around 2012, when we were all still developing VSTO Add-ins. Michael always was very helpful and supporting when I needed information or struggled with issues.

Now get on over to LeanPub site and buy the book!

Did I mention already where to get it?
https://leanpub.com/buildingofficeaddins

I’m sure it will help you and me in learning the details of developing Office Add-ins using Office.js

Xbox at gamescom 2017 Live

XboxGC

Anybody who knows me, knows that besides Technology and Programming I’m very much into Gaming, Music and Movies. Not that I have much time for gaming, it still is one of my ‘big’ things. The technologies used in games often arrive years later in ‘real world’ scenarios. I always wanted to be a games developer (don’t we all?) but ended up to develop Office applications Disappointed smile … Almost the same isn’t it?

I do make (a lot) of time for movies, I have an ‘all you can eat’ subscription for the local cinema and forces me to walk over there instead of driving to keep me a bit healthy. In a way the movie is the ‘reward’ for the walking effort.

Anyway, back to gaming. I’m looking forward to hear and see what is going on with Xbox X (Project Scorpio) and expect to get more information today from gamescom.

Today at 9:00 PM CST, 12:00 PM PDT Xbox @ Gamescom will be broadcasted live from the venue in Germany showing off the news and games for 2017-2018.

You can watch the streams live at:

  • Stream with English Closed Caption: www.mixer.com/Xbox
  • Stream with English Open Captions (burned in video): www.mixer.com/XboxCC
  • Stream with German Open Captions (burned in video): www.mixer.com/XboxCC_DE

  • Also follow the newsfeed on Twitter by keeping an eye on hashtag #XboxGC

    Have fun!

    source: Tune In for Xbox @ gamescom Live This Weekend 

    Office Development – Word.RequestContext vs Word.run

    MinimalCode 2

    Yesterday we’ve seen the minimal code running to insert a bit of text at the selected Range using Word.RequestContext:

    (() => {
    
       async function MinimalWordmethod() {
    
          // Create the client request context. You’ll do this for all 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();
    
    })();

    If you look however at the boilerplate code that is generated with a clean Yeoman project you find that RequestContext is never used, but instead of this you see Word.run(async (context) => { … });

    Why is this and what is the difference? Well, I looked into this and found the answer on a piece of documentation from Michael Zlatkovsky, member of the Office Extensibility Platform team, here:

    http://buildingofficeaddins.com/run

    Michael explains it in his documentation but is written for Excel, however as you can read on the same page it is fully compliant with Word.run.

    Here is a quote from the page:

    You can think of the Excel.run as a boiler-plate preamble; it is the batch function that is the star of the show, but it needs a request context in order to start off the chain of OM calls. The Excel.run call is simply a means to that end, as it creates a new request context that it passes into the batch function.

    Reading this quote explains that by using the <host>.run function you start a batch process, without the trouble of creating your context by yourself. The run function will take care of this for you. So instead of the code where you create your own context object as seen in the snippet above you should be able to run the following code:

    (() => {
       async function MinimalWordmethod() {
    
             // Create the client request context. You’ll do this for al Word add-ins.
             await Word.run(async (context) => {
    
             // Do your things here, such as ..
             var range = context.document.getSelection();
    
             range.insertText("Test run MinimalWordMethod", "After");
    
             await context.sync();
          });
       }
       MinimalWordmethod();
    })();
    

    How to get the new minimal code running

    Go back to the Yeoman project from yesterdays post, open the project folder and open the file app.ts in the src source folder.

    Replace all the code from this file as seen in the top snippet with the code from the second, new snippet 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 will still show you the Add-in button:

    addin7_thumb

    By clicking the button the Taskpane is showing, just like we’ve seen before, but now you should see the words “Test run MinimalWordMethod” in your document:

    MinimalCode3

    Without creating your own context the Word.run function created its own context and the code still works. As you can see this helps you to take some effort out of your hand.

    To be continued …

    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

    %d bloggers like this: