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

VSTO architecture


Architecture is the essential association of a system that comes to life in its components, their associations to each other and to the environment, and the main beliefs guiding its design, and evolution. VSTO applications are composed of Office applications and .NET assemblies.

  • Office applications: VSTO exposes objects that make it easier to program Office applications. These include objects that enhance the application and process the data that the application uses. One of the most important points to understand is that the Word and Excel editors provide a view of a Word or Excel document. Using these editors, you can edit and format the document as though you were working directly in an Office application.

  • .NET assemblies: These contain Intermediate Language(IL) code. Metadata, which is binary information describing your program, is stored in memory and is part of a .NET assembly. In addition to metadata information, assemblies also have a special file called a Manifest. The Manifest contains information about the current version of the assembly.

The core components of VSTO Architecture are document-level customizations, application-level add-ins, and a Data Model at the document level. The new architecture of VSTO allows Office applications to be written and run with macros embedded inside the application.

The preceding image represents the Microsoft Office 2007 Solution Logical Architecture. VSTO enables Office developers to build document-level customizations for InfoPath, Word, and Excel documents, whereas for Outlook, PowerPoint, and Visio, there are no document-level customization features supported by VSTO.

VSTO provides very good support for object-oriented programming, a feature lacking in VBA scripting. VSTO provides full support for the C# programming language, allowing the implementation of object-oriented programming in Office solutions. Object-oriented programming is a kind of programming that relates coding blocks to objects. In other words, object-oriented programming is a software programming approach in which the structures of a program are based on objects' interaction with other objects, in order to perform or execute tasks.VSTO has several objects to work with in order to create applications using VSTO 3.0.

The architectural design of VSTO helps the Office developer in programming separately for application and data. The VSTO architecture design provides enhanced support for developing application-level solutions, and it exposes various objects that will make it easier for Office developers to program for Office applications. The most important point that you have to understand is that Word and Excel are the editors for the data they represent. Using these editors, you can edit and format the visually-displayed data. VSTO exposes a wide range of objects for enhancing the application and for processing the data inside the application for all of the Office applications that support it. Developing application level and document-level solutions is another architectural advancement in VSTO.

Development approaches

The types of solutions that we can create by using VSTO 3.0 fall into two categories, which we will use throughout this book—document-level solutions, and application-level solutions. Let's discuss each briefly.

Document-oriented approach

The document-oriented approach is designed specifically to get to the core of a Word or Excel document and include information that the document wasn't originally designed to support. VSTO 3.0 supports the creation of document-oriented approaches for InfoPath, Word, and Excel. Essentially, document-oriented approaches provide a document pointing to very specific tasks. An example of a document-oriented approach would be where uniform template kind of documents are managed inside a team or company without affecting the application of the document that they reside in.

A point to note is that the document-oriented approach will apply to most, but not all, Office 2007 applications.

Application-oriented approach

VSTO 3.0 is capable of creating application-oriented approaches for all of the applications in the Office 2007 suite. You can create and implement add-ins that add a wide range of functionalities and features to your Office application. The application-oriented approach replaces VBA, and adds new features such as add-ins for 2007 Microsoft Office applications that support enterprise solution development using VSTO. Furthermore, the approach supports the six applications in the 2007 Microsoft Office system, along with the tools and enhanced application programming interfaces(APIs) for customizing the Ribbon UI and creating custom task panes and add-ins. An API is a set of declarations of the functions or procedures provided in order to support requests made by computer programs.