Visual Studio Tools for Office 2007: How the Ribbon Helps Make Your Document a Dynamic Application
In my last article, "Using Visual Studio Tools for Office in Visual Studio 2008," you had a look at the new features of Visual Studio Tools for Office (VSTO) that are shipped along with Visual Studio 2008. You also read a brief discussion on the previous versions of VSTO and went through a walkthrough with the new version to create an "Actions Pane." With this article, you will see a brand new feature of VSTO 2008 that allows the developer to integrate his components directly with the Ribbon interface. You will see what the Ribbon interface is all about and why it is new and special to Office 2007.
For years, people have been used to the two custom toolbars located at the top of Word, Excel, Access, and PowerPoint. Outlook is the only application in Office 2007 that does not have the Ribbon interface. In previous releases of Microsoft Office applications, people used a system of menus, toolbars, task panes, and dialog boxes to get their work done. This system worked well when the applications had a limited number of commands. Now that the programs do so much more, the menus and toolbars system does not work as well. Too many program features are too hard for many users to find.
Microsoft adds new features to each release of Office and makes it more sophisticated and complex than the previous version. With the drawback as explained above, Microsoft had to rethink its strategy when working on this version of Office. So, it completely revamped the entire look and functionality of Office (which was released in late 2006 and named Office 2007). It brought the concept of the Ribbon in Office 2007.
In the Office Fluent UI, the traditional menus and toolbars have been replaced by the Ribbon—a device that presents commands organized into a set of tabs. The tabs on the Ribbon display the commands that are most relevant for each of the task areas in the applications. For example, in Office Word 2007, the tabs group commands for activities such as inserting objects like pictures and tables, doing page layout, working with references, doing mailings, and reviewing. The Home tab provides easy access to the most frequently used commands. Office Excel 2007 has a similar set of tabs that make sense for spreadsheet work, including tabs for working with formulas, managing data, and reviewing. These tabs simplify accessing application features because they organize the commands in a way that corresponds directly to the tasks people perform in these applications. At the time of publishing Office 2007, Microsoft included some enhancements in VSTO and named it VSTO 2003 SE. This included some functionality to enable the programmer to add his own functionality to the Ribbon Interface. But, this wasn't easy for the average developer; he needed some special skills to get a firm understanding of the whole picture.
Revamped Features of VSTO in Visual Studio 2008
With the release of Visual Studio 2008, Microsoft revamped the features in VSTO and released a new version VSTO 3; it is an integral part of Visual Studio 2008 and gives developers a new powerful tool to develop applications directly for the Ribbon interface with the simple ability of dragging and dropping user controls.
Here, you will walk through an example of developing your custom control and displaying it on the Ribbon Interface. This will normally appear in the last tab of the application, namely Add-in. Before you start coding, see why your application will end up in the Add-in Tab. When Microsoft was working on the design of Office 2007, it didn't want to break legacy applications and custom add-ins written for previous version of Office. So, it made a rule that all custom add-ins and custom controls would appear on the last tab of every Office application and that would have its own house—the Add-in Tab. So, when you have Office 2007 open and want to access a specific function written specially for you, you need to look no where except for the Add-in's tab. Isn't that cool enough?
What you will need for this walkthrough: Office 2007 and Visual Studio 2008 (minimum will be the Professional Edition and higher). Make sure that you install all the features, including Visual Studio Tools for Office 3.0.
When you finish your application, it will look like Figure 1. The document loads with the customer names from the "AdventureWorks" database.
Figure 1: The toolbar with your custom application inside the Ribbon.
When you select a particular customer's name from the drop-down list box and click the Show Details button located right below the drop-down list box, the details of purchase made by that customer will appear in the Excel worksheet. The final layout will look like the content of Figure 2.
Figure 2: The desired output after selecting a customer's name and clicking the button.
Page 1 of 5