Chapter 2. Creating a Smart Client for Your Office Business Application by Using VSTO

One of the main strengths of creating an OBA is leveraging Office as your client platform. This smart client application brings together your business application with the Office clients. You are able to tightly integrate your business data and processes into an experience with which the user is comfortable and familiar. As the application developer, you are able to create a richer experience in a shorter period of time using the tools and services provided by Office and Visual Studio. In this chapter, you will see how Visual Studio Tools for Office makes it easy to bring together SharePoint and LOB data into Office applications such as Outlook, Word, and Excel using visual designers and the .NET Framework.

Getting Started with Visual Studio Tools for Office

Visual Studio Tools for Office (VSTO) is a set of technologies that allows Visual Studio developers to create Office applications. VSTO version 3.0 installs as part of Visual Studio Professional 2008. VSTO supports creating Office 2003 and 2007 applications for Word, Excel, Outlook, PowerPoint, Visio, Project, and SharePoint Workflow. VSTO supports creating document-level solutions for Word, Excel, and InfoPath. A document-level solution is loaded when the document, workbook, or form is open; it is unloaded when any of them is closed. VSTO also supports creating add-in solutions. An add-in solution is loaded when the Office application starts, and it is unloaded when the Office application closes. VSTO add-ins are the replacement for the old shared add-ins model.

A Brief History of VSTO

So that you understand where VSTO is today and where it is going tomorrow, you should know how we got here. One of the biggest challenges for VSTO is the fact that the developer division at Microsoft, which includes the VSTO team, is separate from the Office division at Microsoft. This means that they both have their own sets of priorities and ship schedules. Office 2003 was the current version when the VSTO team was formed. The first version of VSTO shipped shortly after for Visual Studio 2003 and targeted Office 2003 Professional Edition. This was a targeted release to get some Office tools to market and generate feedback for the next version. Version 2.0 of VSTO shipped as a standalone SKU based on the Visual Studio 2005 IDE. Version 2.0 was a giant leap forward for VSTO. It included add-in support for Outlook and visual designers for Word and Excel solutions. The number of new features was enormous (for a complete list of features, read the book VSTO for Mere Mortals™: A VBA Developer’s Guide to Microsoft Office Development). Version 2.0 still targeted Office 2003 Professional, but Office 2007 was about to be released the following year. This put VSTO in a tough position because the next version of Visual Studio wasn’t due for a couple of years. What was needed was an add-on to Visual Studio 2005 that targeted the new Office 2007. That release of VSTO was called VSTO Second Edition (SE). It added support for Office 2007 add-ins and increased the number of Office 2003 add-ins as well. And the best part was that it was a free download for Visual Studio. Although VSTO SE enabled Office 2007 developers to create add-ins, they couldn’t easily take advantage of all the new features in Office, such as the Ribbon. This brings us to where we are today. The next major release, Visual Studio 2008, now has VSTO version 3.0 built into the SKU. VSTO version 3.0 adds visual designers for creating Ribbons and Outlook form regions. It supports both Office 2003 Professional and Office 2007 Standard or above.

You will see in this chapter how to take advantage of some of these features to create your Office Business Applications.

Integrated Development Environment (IDE)

VSTO is part of Visual Studio 2008 Integrated Development Environment (IDE). This gives the Office developer all of the power and features of Visual Studio and all of the power and features of the .NET Framework. Figure 2-1 shows what an Excel 2007 project looks like in the IDE.

Project Templates

VSTO ships with a number of Visual Studio project templates. These templates are divided into two major categories: Office 2003 and Office 2007 for both VB and C# languages.

Office 2003

The Office 2003 project folder, seen in Figure 2-2, contains document-level projects for Word, Excel, and InfoPath, and add-in projects for Word, Excel, PowerPoint, Visio, InfoPath, and Outlook. If you are targeting Office 2003 users with your OBA solution, you should install Office 2003 Professional on your development machine to use all of these templates. But if you are targeting a mixed set of users—some on Office 2003 and some on Office 2007—you should install Office 2007. Then you will be able to create a 2003 add-in that will run for both Office 2003 and Office 2007 users. The caveat, of course, is that you must use the lowest-common denominator of features, in this case Office 2003. You could also do work to "light up" Office 2007 features if you detect the version of Office in which your add-in is running.

A VSTO Excel project open in Visual Studio 2008

Figure 2-1. A VSTO Excel project open in Visual Studio 2008

The project types available for Office 2003 development

Figure 2-2. The project types available for Office 2003 development

Office 2007

The Office 2007 project folder, seen in Figure 2-3, contains document-level projects for Word, Excel, and InfoPath. There are add-in projects for Word, Excel, PowerPoint, Project, Visio, InfoPath, and Outlook. There are also two SharePoint server projects for creating sequential and state machine workflows. The two SharePoint projects require that Visual Studio runs on a machine with SharePoint installed. You will use some of these templates in this chapter to create OBAs targeting Office 2007 users.

The project types available for Office 2007 development

Figure 2-3. The project types available for Office 2007 development

Item Templates

There are also a number of item templates that ship with VSTO, seen in Figure 2-4. Item templates are the items that you add to your project. You can open the Add New Item dialog by selecting Project, and then Add New Item from the main menu. The Add New Item dialog contains many project items, but three are for Office projects: Actions Pane Control, Ribbon (XML), and Ribbon (Visual Designer).

The project item types available for Office 2007 development

Figure 2-4. The project item types available for Office 2007 development

Debugging

Debugging Office projects with VSTO is just like other Visual Studio applications, such as a Windows Forms application. You simply need to press F5 to build and run the solution. The VSTO project system will build, deploy, and launch the Office application, and attach the debugger. All of the standard Visual Studio debugging features work with your Office project as well, such as break points, edit and continue, immediate window, and the autos window.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset