SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
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.
“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 in a clear and concise way all of the ins and outs of programming with Visual Studio Tools for Office. 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 allows 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
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.
The complete code samples are available on the book’s Web page.
Why Office Programming? 3
Office Object Models 6
Properties, Methods, and Events 12
The Office Primary Interop Assemblies (PIAs) 34
Conclusion 43
The Three Basic Patterns of Office Solutions 45
Office Automation Executables 49
Office Add-Ins 60
Code Behind a Document 65
Conclusion 72
Ways to Customize Excel 75
Programming User-Defined Functions 83
Introduction to the Excel Object Model 92
Conclusion 98
Events in the Excel Object Model 99
Events in Visual Studio 2005 Tools for Office 138
Conclusion 142
Working with the Application Object 143
Working with the Workbooks Collection 157
Working with the Workbook Object 161
Working with the Worksheets, Charts, and Sheets Collections 169
Working with Document Properties 172
Working with the Windows Collections 175
Working with the Window Object 179
Working with the Names Collection and Name Object 181
Working with the Worksheet Object 183
Working with the Range Object 197
Special Excel Issues 213
Conclusion 220
Ways to Customize Word 223
Programming Research Services 229
Introduction to the Word Object Model 237
Conclusion 238
Events in the Word Object Model 243
Why Are There Multiple Application and Document Event Interfaces? 244
Events in Visual Studio Tools for Office 273
Conclusion 275
Working with the Application Object 277
Working with the Dialog Object 299
Working with Windows 304
Working with Templates 307
Working with Documents 310
Working with a Document 315
Working with the Range Object 335
Working with Bookmarks 358
Working with Tables 360
Conclusion 362
Ways to Customize Outlook 363
Custom Property Pages 370
Introduction to the Outlook Object Model 378
Introduction to the Collaboration Data Objects 382
Conclusion 386
Events in the Outlook Object Model 387
Application-Level Events 392
Outlook Item Events 405
Other Events 419
Conclusion 422
Working with the Application Object 423
Working with the Explorers and Inspectors Collections 431
Working with the Explorer Object 433
Working with the Inspector Object 440
Working with the NameSpace Object 443
Working with the MAPIFolder Object 450
Working with the Items Collection 459
Properties and Methods Common to Outlook Items 466
Outlook Issues 486
Conclusion 492
What Is InfoPath? 493
Getting Started 494
Form Security 499
Programming InfoPath 505
Data Source Events 509
Form Events, Properties, and Methods 518
Conclusion 529
The VSTO Programming Model 533
VSTO Extensions to Word and Excel Objects 536
Dynamic Controls 542
Inspecting the Generated Code 549
VSTO Extensions to the Word and Excel Object Models 555
Conclusion 569
Introduction 571
Adding Windows Forms Controls to Your Document 577
Writing Code Behind a Control 584
The Windows Forms Control Hosting Architecture 585
Properties Merged from OLEObject or OLEControl 594
Adding Controls at Runtime 597
Conclusion 605
Introduction to the Actions Pane 607
Working with the ActionsPane Control 613
Conclusion 628
Introduction to Smart Tags 629
Creating Document-Level Smart Tags with VSTO 633
Creating Application-Level Smart Tags 647
Conclusion 672
Creating a Data-Bound Customized Spreadsheet with VSTO 673
Creating a Data-Bound Customized Word Document with VSTO 681
Datasets, Adapters, and Sources 682
Another Technique for Creating Data-Bound Spreadsheets 691
Caching Data in the Data Island 699
Advanced ADO.NET Data Binding: Looking Behind the Scenes 704
Binding-Related Extensions to Host Items and Host Controls 705
Conclusion 712
Populating a Document with Data on the Server 713
Using ServerDocument and ASP.NET 716
A Handy Client-Side ServerDocument Utility 724
The ServerDocument Object Model 726
Conclusion 737
Code-Access Security Versus Role-Based Security 740
Code-Access Security in .NET 741
Location, Location, Location 749
Strong Names 753
Publisher Certificates 761
Trusting the Document 765
Deploying Policy to User Machines 769
Conclusion 773
VSTO Prerequisites 776
Deploying to an Intranet Shared Directory or Web Site 777
Local Machine Deployment Without a Deployment Manifest 785
Editing Manifests 787
Creating Setup Packages 793
Conclusion 805
Introduction to Excel’s XML Features 809
Introduction to XML Schema Creation in Visual Studio 811
An End-to-End Scenario 816
Advanced XML Features in Excel 826
Excel-Friendly XML Schemas 830
VSTO Support for Excel Schema Mapping 833
Conclusion 849
Introduction to Word’s XML Features 851
An End-to-End Scenario: Creating a Schema and Mapping It into a Word Document 855
Exporting the Mapped XML in the Document to an XML Data File 869
Importing an XML Data File into the Mapped Document 871
The XML Options Dialog Box 877
VSTO Support for Word Schema Mapping 880
VSTO Support for the WordML File Format 888
Conclusion 889
Introduction to Add-Ins 891
Scenarios for Using Add-Ins 892
How a COM Add-In Is Registered 893
Implementing IDTExtensibility2 897
Writing a COM Add-In Using Visual Studio 904
The Pitfalls of mscoree.dll 914
COM Interop and regasm.exe 914
Shimming: A Solution to the Problems with mscoree.dll 919
Conclusion 920
Moving Away from COM Add-Ins 921
Creating an Outlook Add-In in VSTO 933
Conclusion 940