Office 2007 Deployment: Let's Get Visual (Visual Studio 2008 Overview)

Monday was exciting wasn’t it? Snow everywhere and a fair number of people forced to enjoy themselves in the event transport links ground to a halt. But that excitement doesn’t come close to what we are going to look at in this post; Visual Studio 2008

Now the one question you will have right now is: What does Visual Studio have to do with Office 2007? At first glance you may wonder whether or not this has to do with Macro programming within the new suite. But for our purposes, it’s actually something quite different.

As part of the rollout, we were asked to include a number of offline documents and flash based programs we recieved from Microsoft which inform users about what’s new in Office 2007 and also to show where features have been moved to under the new interface as shown below;


The reasoning behind this is straight forward. The interface for Office 2007 is different to that of what came before for Office 97,2000,XP and 2003 with the introduction of the ribbon which groups tasks together under different tabs. Some form of online help would help any users having issues with how to do things in the short term with long term training to be applied as required.

To achieve what we need, we could just copy the help files over to the local users workstations, create a shortcut to the folder on the desktop and fall back asleep.

But why can’t we do something which calls the help files from within Office itself? Well that is where Visual Studio 2008 comes into play. You see, Visual Studio 2008 introduces customisation of the Office 2007 ribbon interface where you can add extra tabs with functions your company may require, links to external programs like what we are doing and even cut down the main interface of Office which gives you the oppotunity to make it even easier for users to use.

We’ll now go into Visual Studio 2008 and some of the process for creating custom tabs but this is by no means a complete guide, more than likely someone will need to have a look around to see if this adds any value to the rollout you are performing.

We’ll start at the create new project stage;


Now in order to create a new add-in as it’s called under Visual Studio, you need to be sure that the selected version of .net frameworks is set to 3.5. If not, you won’t see the options to create it in the first place. We have chosen to create it using Visual Basic as it’s a fairly simple langauge to code in and for our purposes of launching external programs, more than enough.

Note: Don’t use the character ‘ in the name of the files as you will encounter a “Customization could not be loaded because the application domain could not be created.” and more than likely you’ll start pulling your hair out as to why it doesn’t work. Just keep your file names simple. Trust me!

Now to start with you won’t have much in terms of usable objects, in fact all you will see is this;


Basically there is nothing there. We have to add the ribbon to the project so what you need to is right click on the project name under Solution Explorer and select add – new item as shown below;


At the next stage you will presented with the add new dialog from which you can select a whole host of items to include in the add-in if required. For the purpose of this however the only option we want to add is the Ribbon (Visual Designer) template as that is the quickest way to make our ribbon for what we want it to do.

One you’ve added that option you should be presented with the office ribbon as a blank area for you to add items as you see fit;


Now using the toolbox you drag things across and then edit the properties of whatever object you’ve selected. You double click on the object which opens up the code relating to that object and what you want to happen when the user interacts with that object. All the goodness you would expect from a programming tool.

There were a couple of things we did change during the creation of the Ribbon toolbar for MediaEdge which changed the behaviour of the tab itself which will be of great use to you during the creation of the ribbon interface for your needs.

The initial ribbon you have created is set to take over from the Add-ins tab under Office 2007, the tab which is used to contain Add-ins released for earlier versions of Office. If you customise that one, the Add-ins tab will be named what you call the tab and basically gets a little confusing.

To make sure that you custom tab doesn’t take over the Add-ins tab in anyway, you need to change the “ControlIDType” of the Tab in the properties of the object from Office to Custom. The tab will then appear by itself without altering the Add-in tab or any other built-in office tab which already exists.

The PositionID under the Layout Options of the properties of the tab you can use to dictate where the custom tab will appear, either before the Built-in tabs from Office or after, via entering a number for the ID of the Tab you wish to postion. We left it at “default” as it didn’t matter to us.

And now we enter the main part of the affair; Add a button to a tab and make it open an external program.

To add a button, you just drag from the Toolbox over to where you want the button to appear. You will see just some text for the start, but then you can customise the button to include an image, some text when someone hovers over it, a picture to go with the button, basically all sorts of options under the properties pain for that button. Visual Studio explains what each part is and how it plays a part in the object’s behaviour so I won’t go into detail here about it.

So after altering properties of the various objects like the tab, the group and the button we have something like this (Blue Peter style) and within the example picture you can see some of the properties we have altered already:


CWRibbon2.gifSo now we need that button to do something. Double click it and you will be presented with the code window with the cursor at the area for the button, probably showing text like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click

End Sub

Now it is here that we need to call that external program outside of the ribbon. The command we’re using is:


so the whole thing just looks like this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles Button1.Click


End Sub

Basically we ask the program to start cmd.exe when someone clicks the button. Nice and straight forward. Run the ribbon by clicking on the “Play” button and then Office loads with something like this:

img class="mt-image-center" height="265" alt="Wordshowingaddin.gif" src="" width="400" />When you click it, a command window should open and there you are, a customised Office Ribbon. You can close Word and go back to Visual Studio, alter things and test again, whatever you like to fit the needs as to what you want to include.

For our part, we’ll be including links to all the relevant documents for each program we’re going to customise, Word, Excel and Powerpoint. This is achieved by adding new items just like we did earlier and then testing them to make sure that they perform the functions we require. Therefore users have access to help within Office and provides a more polished solution. 

After all that excitement, we’ll need to publish it and save the files to a network location you will install from because we are going to siliently install the ribbon within the next part of the logon script. To do that, you’ll need to run through the “Publish Wizard” and make sure you select on the second page “From a CD-ROM or DVD-ROM” for the default installation path. 

Visual Studio Runtime files which can be deployed to user’s workstations include VSTOinstaller.exe which you can use to siliently install the resultant VSTO file which appears when you’ve published it. Or you can create a set-up program with pre-requisite checks which will install things before it then proceeds to install the ribbon.

So there you are, that’s how Visual Studio 2008 has come into play for this rollout. However the install process is not an easy one, and I’ll explain why in the next post.