Home > Store

Visual Studio Tools for Office 2007: VSTO for Excel, Word, and Outlook

Register your product to gain access to bonus material or receive a coupon.

Visual Studio Tools for Office 2007: VSTO for Excel, Word, and Outlook


  • Sorry, this book is no longer in print.
Not for Sale

eBook (Watermarked)

  • Your Price: $46.39
  • List Price: $57.99
  • Includes EPUB and PDF
  • About eBook Formats
  • This eBook includes the following formats, accessible from your Account page after purchase:

    ePub EPUB The open industry format known for its reflowable content and usability on supported mobile devices.

    Adobe Reader PDF The popular standard, used most often with the free Acrobat® Reader® software.

    This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.


  • Copyright 2009
  • Dimensions: 7" x 9-1/4"
  • Pages: 1120
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-53321-6
  • ISBN-13: 978-0-321-53321-0

Visual Studio Tools for Office 2007: VSTO for Excel, Word, and Outlook is the definitive book on VSTO 2008 programming, written by the inventors of the technology. VSTO is a set of tools that allows professional developers to use the full power of Microsoft Visual Studio 2008 and the .NET Framework to program against Microsoft Office 2007.

This book delivers in one place all the information you need to succeed using VSTO to program against Word 2007, Excel 2007, and Outlook 2007, and provides the necessary background to customize Visio 2007, Publisher 2007, and PowerPoint 2007. It introduces the Office 2007 object models, covers the most commonly used objects in those object models, and will help you avoid the pitfalls caused by the COM origins of the Office object models. Developers who wish to program against Office 2003 should consult Carter and Lippert’s previous book, Visual Studio Tools for Office.

In VSTO 2008, you can build add-ins for all the major Office 2007 applications, build application-level custom task panes, customize the new Office Ribbon, modify Outlook’s user interface using Form Regions, and easily deploy everything you build using ClickOnce.

Carter and Lippert cover their subject matter with deft insight into the needs of .NET developers learning VSTO, based on the deep knowledge that comes from the authors’ unique perspective of living and breathing VSTO for the past six years. This book 

  • Explains the architecture of Microsoft Office programming and introduces the object models
  • Covers the main ways Office applications are customized and extended
  • Explores the ways of customizing Excel, Word, and Outlook, and plumbs the depths of programming with their events and
    object models
  • Introduces the VSTO programming model
  • Teaches how to use Windows Forms and WPF in VSTO and how to work with the Document Actions Pane and application-level task panes
  • Delves into VSTO data programming and server data scenarios
  • Teaches ClickOnce VSTO deployment

This is the one book you need to succeed in programming against Office 2007.

NOTE: This is now a two volume set

C# and Visual Basic .NET Code samples for download can be found here: http://www.informit.com/store/product.aspx?isbn=0321533216


Author's Site

Please visit the author's website at blogs.msdn.com/eric_carter for further resources.

Sample Content

Online Sample Chapter

Working with Outlook Form Regions

Sample Pages

Download the sample pages (includes Chapter 16 and Index)

Table of Contents

Figures xxxi

Tables xlv

Foreword li

Preface lv

Acknowledgments lix

About the Authors lxi


Part I: An Introduction to VSTO 1


Chapter 1: An Introduction to Office Programming 3

Why Office Programming? 3

Office Business Applications 3

Office Object Models 7

Properties, Methods, and Events 14

The Office Primary Interop Assemblies (PIAs) 39

Conclusion 48

Chapter 2: Introduction to Office Solutions 51

The Three Basic Patterns of Office Solutions 51

Office Automation Executables 54

Office Add-Ins 69

Code Behind a Document 78

Conclusion 86

Part II: Office Programming in .NET 87

Chapter 3: Programming Excel 89

Ways to Customize Excel 89

Programming User-Defined Functions 98

Introduction to the Excel Object Model 108

Conclusion 112

Chapter 4: Working with Excel Events 115

Events in the Excel Object Model 115

Conclusion 162

Chapter 5: Working with Excel Objects 163

Working with the Application Object 163

Working with the Workbooks Collection 178

Working with the Workbook Object 181

Working with the Worksheets, Charts,

Working with Document Properties 192

Working with the Windows Collections 195

Working with the Window Object 199

Working with the Names Collection and Name Object 202

Working with the Worksheet Object 204

Working with the Range Object 219

Special Excel Issues 235

Conclusion 241

Chapter 6: Programming Word 243

Ways to Customize Word 243

Programming Research Services 249

Introduction to the Word Object Model 261

Conclusion 262

Chapter 7: Working with Word Events 267

Events in the Word Object Model 267

Events in Visual Studio Tools for Office 307

Conclusion 310

Chapter 8: Working with Word Objects 311

Working with the Application Object 311

Working with the Dialog Object 332

Working with Windows 338

Working with Templates 341

Working with Documents 343

Working with a Document 348

Working with the Range Object 369

Working with Bookmarks 392

Working with Tables 394

Working with Content Controls 396

Conclusion 403

Chapter 9: Programming Outlook 405

Ways to Customize Outlook 405

Introduction to the Outlook Object Model 419

Conclusion 422

Chapter 10: Working with Outlook Events 425

Events in the Outlook Object Model 425

Application-Level Events 427

Outlook Item Events 448

Other Events 470

Conclusion 473

Chapter 11: Working with Outlook Objects 475

Working with the Application Object 475

Working with the Explorers and Inspectors Collections 486

Working with the Explorer Object 488

Working with the Inspector Object 501

Working with the NameSpace Object 506

Working with the Folder Object 519

Working with the Items Collection 534

Properties and Methods Common to Outlook Items 548

Conclusion 569

Part III: Office Programming in VSTO 571

Chapter 12: The VSTO Programming Model 573

The VSTO Programming Model for Documents 573

VSTO Extensions to Word and Excel Document Objects 576

Dynamic Controls in the Document 584

Advanced Topic: Class Hookup and Cookies 591

Advanced Topic: Inspecting the Generated Code 594

VSTO Extensions to the Word and Excel Object Models 599

The VSTO Programming Model for Add-Ins 619

Using VSTO Document Features in Application-Level Add-Ins 621

Advanced Topic: Creating Worksheets Dynamically 624

Conclusion 625

Chapter 13: Using Windows Forms and WPF in VSTO 627

Introduction 627

Adding Windows Forms Controls to Your Document 634

Writing Code Behind a Control 641

The Windows Forms Control Hosting Architecture 643

Properties Merged from OLEObject or OLEControl 654

Adding Controls at Runtime 658

Using WPF Controls in the Document 669

Conclusion 671

Chapter 14: Working with Document-Level Actions Panes 673

Introduction to the Document Actions Task Pane 673

Working with the ActionsPane Control 680

Using WPF Controls in an Actions Pane 697

Conclusion 699

Chapter 15: Working with Application-Level Custom Task Panes 701

Introduction to the Application-Level Custom Task Panes 701

Working with Custom Task Panes 704

Custom Task Panes and Application Windows 710

Using WPF Controls in a Custom Task Pane 719

Conclusion 722

Chapter 16: Working with Outlook Form Regions 723

Introduction to Form Regions 723

Form Region Types and Custom Message Classes 743

Creating an Outlook Forms-Based Form Region 749

Outlook Form Region Programmability 765

Conclusion 774

Chapter 17: Working with the Ribbon in VSTO 777

Introduction to the Office Ribbon 777

Working with the Ribbon in the Ribbon Designer 800

Creating a Ribbon in an Excel Workbook Project 812

Creating a Ribbon in an Outlook Add-In Project 825

Advanced Ribbon Topics 836

Conclusion 850

Chapter 18: Working with Smart Tags in VSTO 851

Introduction to Smart Tags 851

Creating Document-Level Smart Tags with VSTO 855

Creating Application-Level Smart Tags 874

Conclusion 880

Chapter 19: VSTO Data Programming 881

Creating a Data-Bound Customized Spreadsheet with VSTO 882

Creating a Data-Bound Customized Word Document with VSTO 889

Datasets, Adapters, and Sources 891

Another Technique for Creating Data-Bound Documents 901

Caching Data in the Data Island 908

Advanced Topic: Using ICachedType 911

Advanced ADO.NET Data Binding: Looking Behind the Scenes 913

Binding-Related Extensions to Host Items and Host Controls 914

Using Data Binding and Dynamic Controls from an Application-Level Add-In 921

Conclusion 928

Chapter 20: Server Data Scenarios 929

Populating a Document with Data on the Server 929

Using ServerDocument and ASP.NET 931

A Handy Client-Side ServerDocument Utility 939

The ServerDocument Object Model 941

Conclusion 952

Chapter 21: ClickOnce Deployment 955

Introduction 955

Prerequisites 956

Deploying Add-Ins 958

Deploying Document Solutions 982

ClickOnce Security 995

Other Deployment Scenarios 1009

Advanced Topic: Editing Manifests Using Mage 1010

Conclusion 1015

Bibliography 1017

Index 1019


Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020