Book Image

VSTO 3.0 for Office 2007 Programming

By : Vivek Thangaswamy
Book Image

VSTO 3.0 for Office 2007 Programming

By: Vivek Thangaswamy

Overview of this book

With the arrival of Visual Studio Tools for Office 3.0 (VSTO), developers can now program Microsoft Office from the .NET framework. There are huge books in the market that give loads of unnecessary information but are of no real help to brand-new Office developers. Wouldn't it be great to have a precise book that simply covers the basics and introduces programming Office 2007 with VSTO using the latest version of Visual Studio? This is that book. VSTO 3.0 for Office 2007 Programming shows you how to write Office 2007 applications with Visual Studio Tools for Office 3.0. Learn how to automate tasks in InfoPath, Word, Excel, Outlook, PowerPoint, Visio, and Project 2007 with greater programming power and flexibility than was available from the VBA language. With this book and the mastery of VSTO you will learn, Office will no longer be an application to you; it will be a platform for developing custom applications.VSTO 3 is the most recent version of VSTO, making use of Visual Studio 2008, and working with Office 2007. This book shows how VSTO puts Office automation into the hands of developers, allowing them to use the power of the .NET framework to automate Office applications thus increasing the speed of the applications, their security, and the opportunity to use other parts of the .NET Framework such as its data handling capabilities. This book builds a solid programming foundation in VSTO for brand-new Office developers. You will leave behind the world of VBA programming and take your first steps into the powerful and exciting world of using C# to create Office 2007 applications. Packed with examples and covering all the main Office applications, this book will have you creating fully featured Office extensions before you know it.
Table of Contents (11 chapters)
VSTO 3.0 for Office 2007 Programming
Credits
About the Author
About the Reviewers
Preface

Visual Studio integration


VSTO 3.0 provides a visual representation of Office applications inside the Visual Studio, in order to easily create a customized user interface. VSTO 3.0 is well integrated with Visual Studio 2008, which provides the integrity for Office developers to develop and deploy Microsoft Office solutions for Microsoft Office tools. Visual Studio 2008 enables developers to build scalable Office business applications, influence key Office UI features, support workflow, and create easier deployments. Office development is a part of Visual Studio 2008 Professional and later versions, which focuses mainly on the developers' compatibility and maintainability assurances.

Let's take a look at a typical VSTO project template for an Office 2007 application in Visual Studio 2008.

In the preceding image, you can see the VSTO project templates for Office 2007 applications in Visual Studio 2008. Visual Studio 2008 has been packed with all of the VSTO 3.0 components needed to build an Office solution using VSTO. When installing Visual Studio 2008, all of the related installations, including project templates for VSTO 3.0, Office development references, and others, have been installed and fully-integrated into the new Visual Studio 2008 development environment.

Creating VSTO solutions

Visual Studio 2008 is very fast, collaborative, and flexible in developing and delivering a wave of innovative new Microsoft technologies, including enhanced language and data features. C# and VB.NET programming supported in Office 2007 is one of the enhanced language features, and easy data interaction with other data sources, such as Microsoft SQL server, is one of the data features. These features ensure that developers can rapidly create connected applications, deliver next generation software practices, and overcome application software development challenges.

The preceding image represents the development environment of the Office solution. In this figure, the client represents the development environment machine; the VSTO 3.0 inside Visual Studio 2008 represents the VSTO integrated Visual Studio; Office 2007 Client tools are the Office applications, including Word, Excel, InfoPath, and others, that should be installed in the client machine for development.

The development environment using Visual Studio 2008 is capable of creating application-level, data-centric solutions with VSTO 3.0. The data-centric solutions are the functionalities that are siginificantly focused on data manipulation and data storage.

The Visual Studio 2008 development environment makes it possible to develop solutions with great design-time and runtime support for key Office 2007 System features, such as the Ribbon, Custom Task Panes, document-level solutions, Outlook forms regions, and so on.

The Ribbon is a new way of representing menu items in the Office application. In the new development environment, you have a visual designer within which you can drag-and-drop controls inside the Ribbon, and design your custom Ribbon menus easily. Even for a data-related operation such as creating data connections, you have a data connection wizard for easy creation of a data connection.

Let's take a look at how the Office project solution looks, once it's been created in Visual Studio 2008. For example, we'll load a Word 2007 document solution created with Visual Studio 2008 and VSTO, using project templates available in the development environment:

The preceding image represents how the Office project solution for Word 2007 has been created in Visual Studio 2008. You can see all of the references listed as System.AddIn, System.Core, and so on. These are loaded automatically as a part of the project template. This provides the developer with easy-to-start programming by eliminating the manual process of adding references and validating the solution.

Office developers can integrate business data into documents by using XML-based data/view separation and programmability. For example, in InfoPath, you can easily integrate business data with the InfoPath forms, and you can program the data of the InfoPath, storing it as a separate file in XML format. You can also present the data in different views, depending on how the user wants to see it, in the user interface. You can develop solutions using the combined Outlook object model.

Viewing IDE Windows

Visual Studio is a fabulous Microsoft product designed especially for development activities. It is one of the most widely-used development tools among developers across the globe. It is built on an IDE, and enables developers to build different types of applications using Microsoft technologies. IDE is a software application for developing new software programs and applications that provides broad facilities to programmers for software development.

In general, IDE consists of a source code editor, compilers, and debuggers. Most readers will be familiar with the Visual Studio IDE. Visual Studio 2008 has an appearance similar to previous IDEs, but with more enhancements. By default, Microsoft Visual Studio IDE will provide you with IntelliSense, debugging, compilers for .NET programming, access to control controls, and the ability to build solutions. The latest enhancements such as visual designer for Ribbon, drag-and-drop controls, and enhanced debugging for Office applications will reduce the development time and increase the productivity of developers.

The in-built VSTO object model is designed to support .NET. And it's also simple! Many common functions are packaged and well-integrated. In the new version, tools such as Word, Excel, and InfoPath's target windows, are integrated directly into the IDE interface. This helps Office developers to build solutions without needing an advanced knowledge of the underlying object model. VSTO also has visual designers for Word 2007 and Excel 2007 that are in the Visual Studio IDE.

In the preceding image, we can see how the visual designer for Word 2007 appears in Visual Studio 2008. In this environment, you have the drag-and-drop functionality and other easy-to-design layouts for the use of an Office developer. Visual Studio 2008 brings the visual designer for other Office tools such as Excel and Infopath into the IDE. In a similar way, the Visual Studio 2008 IDE brings the visual Ribbon designer for Office tools into the interface. The Ribbon designer allows an Office developer to visually design an Office Ribbon (officially called the Office Fluent user interface) using the well-known drag-and-drop interface, and interact with the Ribbon using standard .NET code.

The preceding image shows the visual designer for the Ribbon in Office solution development, which simplifies the Ribbon development process for Office developers by providing drag-and-drop controls and easy access to resources. Similarly, Visual Studio 2008 simplifies and speeds up the development process of the actions pane, document-specific Task Panes, creating application-specific custom Task Panes, and Outlook Form Region Designer.

Debugging

Debugging is one of the most important tasks in software development, and a task that all developers will have run into many times in their programming lives. Developers have several debugging alternatives available for debugging their .NET applications that have DLL files in the Visual Studio IDE.

Visual Studio 2008 provides a strong set of build and debugging tools for Office solution development using VSTO 3.0. This is a big improvement over VSTO 2.0, which did not provide preconfigured debugging options. During configuration of the build, developers can select the components that they want to build, and exclude those that they want to avoid for the current build. A developer has the flexibility to build configurations for solutions as well as projects.