Home > Store

Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath

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

Visual Studio Tools for Office: Using C# with Excel, Word, Outlook, and InfoPath

Book

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

About

Features

Direct from two of the lead developers of the product comes the definitive guide to using Visual Studio Tools for Office (VSTO) 2005.

° VSTO 2005 is a major new developer tool from Microsoft, and is a huge improvement over the first version. Usage should increase dramatically.

° Authors are two of the lead developers of VSTO, and the entire VSTO team is supporting the book.

° Both an overview of the product as well as a practical tutorial.

° Will be the first book on VSTO.

Description

  • Copyright 2006
  • Dimensions: 7" x 9-1/4"
  • Pages: 1008
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-33488-4
  • ISBN-13: 978-0-321-33488-6

"With the application development community so focused on the Smart Client revolution, a book that covers VSTO from A to Z is both important and necessary. This book lives up to big expectations. It is thorough, has tons of example code, and covers Office programming in general terms— topics that can be foreign to the seasoned .NET developer who has focused on ASP.NET applications for years. Congratulations to Eric Lippert and Eric Carter for such a valuable work!"

—Tim Huckaby, CEO, InterKnowlogy, Microsoft regional director

"This book covers all of the ins and outs of programming with Visual Studio Tools for Office in a clear and concise way. Given the authors' exhaustive experiences with this subject, you can't get a more authoritative description of VSTO than this book!"

—Paul Vick, technical lead, Visual Basic .NET, Microsoft Corporation

"Eric and Eric really get it. Professional programmers will love the rich power of Visual Studio and .NET, along with the ability to tap into Office programmability. This book walks you through programming Excel, Word, InfoPath, and Outlook solutions."

—Vernon W. Hui, test lead, Microsoft Corporation

"This book is an in-depth, expert, and definitive guide to programming using Visual Studio Tools for Office 2005. It is a must-have book for anyone doing Office development."

—Siew Moi Khor, programmer/writer, Microsoft Corporation

"We don't buy technical books for light reading; we buy them as a resource for developing a solution. This book is an excellent resource for someone getting started with Smart Client development. For example, it is common to hear a comment along the lines of, 'It is easy to manipulate the Task Pane in Office 2003 using VSTO 2005,' but until you see something like the example at the start of Chapter 15, it is hard to put 'easy' into perspective. This is a thorough book that covers everything from calling Office applications from your application, to building applications that are Smart Documents. It allows the traditional Windows developer to really leverage the power of Office 2003."

—Bill Sheldon, principal engineer, InterKnowlogy, MVP

"Eric Carter and Eric Lippert have been the driving force behind Office development and Visual Studio Tools for Office 2005. The depth of their knowledge and understanding of VSTO and Office is evident in this book. Professional developers architecting enterprise solutions using VSTO 2005 and Office System 2003 now have a new weapon in their technical arsenal."

—Paul Stubbs, program manager, Microsoft Corporation

"This book is both a learning tool and a reference book, with a richness of tables containing object model objects and their properties, methods, and events. I would recommend it to anyone considering doing Office development using the .NET framework; especially people interested in VSTO programming."

—Rufus Littlefield, software design engineer/tester, Microsoft Corporation

Visual Studio Tools for Office is both the first and the definitive book on VSTO 2005 programming, written by the inventors of the technology. VSTO is a set of tools that allow professional developers to use the full power of Visual Studio .NET and the .NET Framework to put code behind Excel 2003, Word 2003, Outlook 2003, and InfoPath 2003. VSTO provides functionality never before available to the Office developer: data binding and data/view separation, design-time views of Excel and Word documents inside Visual Studio, rich support for Windows Forms controls in a document, the ability to create custom Office task panes, server-side programming support against Office, and much more.

Carter and Lippert cover their subject matter with deft insight into the needs of .NET developers learning VSTO. This book

  • Explains the architecture of Microsoft Office programming and introduces the object models

  • Teaches the three basic patterns of Office solutions: Office automation executables, Office add-ins, and code behind a document

  • Explores the ways of customizing Excel, Word, Outlook, and InfoPath, and plumbs the depths of programming with their events and object models

  • Introduces the VSTO programming model

  • Teaches how to use Windows Forms in VSTO and how to work with the Actions Pane

  • Delves into VSTO data programming and server data scenarios

  • Explores .NET code security and VSTO deployment

Advanced material covers working with XML in Word and Excel, developing COM add-ins for Word and Excel, and creating Outlook add-ins with VSTO.


© Copyright Pearson Education. All rights reserved.

Sample Content

Online Sample Chapters

Introduction to Office Solutions Using Visual Studio Tools for Office

Introduction to Office Solutions Using Visual Studio Tools for Office

Downloadable Sample Chapter

Download the Sample Chapter related to this title.

Table of Contents

About the Authors.

Preface.

Acknowledgments.

Foreword.

I. AN INTRODUCTION TO VSTO.

1. An Introduction to Office Programming.

2. Introduction to Office Solutions.

II. OFFICE PROGRAMMING IN .NET.

3. Programming Excel.

4. Working with Excel Events.

5. Working with Excel Objects.

6. Programming Word.

7. Working with Word Events.

8. Working with Word Objects.

9. Programming Outlook.

10. Working with Outlook Events.

11. Working with Outlook Objects.

12. Introduction to InfoPath.

III. OFFICE PROGRAMMING IN VSTO.

13. The VSTO Programming Model.

14. Using Windows Forms in VSTO.

15. Working with Actions Pane.

16. Working with Smart Tags in VSTO.

17. VSTO Data Programming.

18. Server Data Scenarios.

19. .NET Code Security.

20. Deployment.

IV. ADVANCED OFFICE PROGRAMMING.

21. Working with XML in Excel.

22. Working with XML in Word.

23. Developing COM Add-Ins for Word and Excel.

24. Creating Outlook Add-Ins with VSTO.

Index.

Preface

In 2002, the first release of Visual Studio .NET and the .NET Framework was nearing completion. A few of us at Microsoft realized that Office programming was going to miss the .NET wave unless we did something about it.

What had come before was Visual Basic for Applications (VBA), a simple development environment integrated into all the Office applications. Each Office application had a rich object model that was accessed via a technology known as COM. Millions of developers identified themselves as "Office developers" and used VBA and the Office COM object models to do everything from automating repetitive tasks to creating complete business solutions that leveraged the rich features and user interface of Office. These developers realized that their users were spending their days in Office. By building solutions that ran inside of Office, they not only made their users happy, they were also able to create solutions that did more and cost less by reusing functionality already available in the Office applications.

Unfortunately, because of some limitations of VBA, Office programming was starting to get a bad rap. Solutions developed in VBA by small workgroups or individuals would gain momentum and a professional developer would have to take them over and start supporting them. To a professional developer, the VBA environment felt simple and limited, and of course, it enforced a single language: Visual Basic. VBA embedded code in every customized document, which made it hard to fix bugs and update solutions because a bug would get replicated in documents across the enterprise. Security weaknesses in the VBA model led to a rash of worms and macro viruses that made enterprises turn VBA off.

Visual Studio .NET and the .NET Framework provided a way to address all these problems. A huge opportunity existed to not only combine the richness of the new .NET Framework and developer tools with the powerful platform that Office has always provided for developers but to also solve the problems that were plaguing VBA. The result of this realization was Visual Studio Tools for Office (VSTO).

The first version of VSTO was simple, but it accomplished the key goal of letting professional developers use the full power of Visual Studio .NET and the .NET Framework to put code behind Excel 2003 and Word 2003 documents and templates. It let professional developers develop Office solutions in VB.NET and C#. It solved the problem of embedded code by linking a document to a .NET assembly instead of embedding it in the document. It also introduced a new security model that used .NET code-access security to prevent worms and macro viruses.

The second version of VSTO, known as VSTO 2005, the version of VSTO covered by this book, is even more ambitious. It brings with it functionality never available to the Office developer before, such as data binding and data/view separation, design-time views of Excel and Word documents inside Visual Studio, rich support for Windows Forms controls in the document, the ability to create custom Office task panes, server-side programming support against Office—and that's just scratching the surface. Although the primary target of VSTO is the professional developer, this does not mean that building an Office solution with VSTO is rocket science. VSTO makes it possible to create very rich applications with just a few lines of code.

This book tries to put into one place all the information you need to succeed using VSTO to program against Word 2003, Excel 2003, Outlook 2003, and InfoPath 2003. It introduces the Office object models and covers the most commonly used objects in those object models. In addition, this book will help you avoid some pitfalls that result from the COM origins of the Office object models.

This book also provides an insider view of all the rich features of VSTO. We participated in the design and implementation of many of these features. We can therefore speak from the unique perspective of living and breathing VSTO for the past three years. Programming Office using VSTO is powerful and fun. We hope you enjoy using VSTO as much as we enjoyed writing about it and creating it.

Eric Carter
Eric Lippert

May 2005

Bibliography

Untitled Document

Security
LaMacchia, Brian - Lange, Sebastian - Lyons, Matthew - Martin, Rudi - Price, Kevin T.
.NET Framework Security
Addison-Wesley, 2002

Lippert, Eric
Visual Basic .NET Code Security Handbook
Wrox Press, 2002

Howard, Michael - LeBlanc, David
Writing Secure Code, 2nd Edition
Microsoft Press, 2003

Office Programming
Whitechapel, Andrew
Microsoft .NET Development for Microsoft Office
Microsoft Press, 2004

Mosher, Sue
Microsoft Outlook Programming
Digital Press, 2002

Data Programming
Homer, Alex - Sussman, Dave - Fussell, Mark
A First Look at ADO.NET and System.Xml v. 2.0
Addison-Wesley, 2004

Wildermuth, Shawn
Pragmatic ADO.NET
Addison-Wesley, 2003

Forms Programming
Sells, Chris - Gehtland, Justin
Windows Forms Programming in Visual Basic .NET
Addison-Wesley, 2004

Sells, Chris
Windows Forms Programming in C#
Addison-Wesley, 2004

Infrastructure
Hejlsberg, Anders - Wiltamuth, Scott - Golde, Peter
The C# Programming Language
Addison-Wesley, 2004

Box, Don - Skonnard, Aaron - Lam, John
Essential XML: Beyond Markup
Addison-Wesley, 2000

Nathan, Adam
.NET and COM: The Complete Interoperability Guide
Sams Publishing, 2002

Index

Download the Index file related to this title.

Updates

Errata

Untitled Document Errata for First Edition of Visual Studio Tools for Office

Chapter 1:

• Table 1-3, page 27: The event name "ShetFollowHyperlink" should be "SheetFollowHyperlink"
• Listing 1-20, page 31: The variable myBtn should be renamed to btn to match the explanatory text on page 30. The myBtn_Click method should similarly be renamed to btn_Click for continuity.

Chapter 3:

• Listing 3-1, page 88: The line of code that reads:

[ClassInterface(ClassInterfaceType.AutoDual)]

should instead be

[ClassInterface(ClassInterfaceType.AutoDual), ComVisible(true)]

• Page 90: When you add the AutomationAddin.MyFunctions class to the list of automation add-ins, you may get an error from Excel about mscoree. Be sure to click the No button if this error dialog appears otherwise the add-in will be removed from the list of installed automation add-ins.

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.

Overview


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.

Surveys

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.

Newsletters

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.

Security


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

Children


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

Marketing


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.

Choice/Opt-out


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.

Links


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