[Blog Map] This blog is inactive. New blog: EricWhite.com/blog
Extending Microsoft Word 2010 is one of the most effective ways to augment content and enable richer collaboration around documents. There are many ways to extend Microsoft Word 2010 and integrate user-friendly and powerful document editing into your application. Extending Word is the most common way to develop for Microsoft Office.
This post is one in a series on Microsoft Office 2010 application development. These posts will be published in the future as part of an MSDN article. As usual, after the MSDN article is published, I’ll place pointers in the blog posts to the article on MSDN.
In this series of posts, I'll be publishing a post on each of the Office client applications, listing the developer building blocks for it. I put the various developer building blocks into one of four categories:
· User Interface Extensions – You use these building blocks to create custom ribbons, custom user interfaces, extend content menus, and more.
· Canvas Extensions – Available only in Microsoft Word and Microsoft Excel , canvas extensions are those extensibility points that enable you to add controls to the surface of a document or spreadsheet. You can add controls to the surface of a document to create more interactivity for users.
· Programmability Extensions – In combination with user interface and canvas extensions, you use programmability extensions to build customizations and add-ins.
· Supported for Previous Versions – listed for completeness, instead of using these legacy technologies, Microsoft recommends using newer approaches for programmability using managed add-ins, customizations, and user interface extensions.
In addition to extending the Word user interface on client computers, developers take advantage of services on servers such as Word Automation Services or WCF services to build distributed applications with rich functionality. Using the Open XML SDK on servers enables you to develop enterprise-quality bulk document generation applications that perform well and are robust.
Developer Center: Word Developer Center
Technical Articles: Word 2010 Technical Articles
Technical Articles: Word 2007 Technical Articles
Videos: Word Visual How Tos
Extend the user interface by creating a customizable pane for document-level solutions.
Customize the backstage view enables you to display information about documents to users.
Customize the context menu to make custom features easy to use.
Custom Task Pane
Extend the user interface by creating a customizable pane for application-level solutions.
Document Information Panel
Enable users to enter metadata about a document.
Customize the ribbon to augment the editing experience of the document and make the features of your add-in more discoverable.
Use content controls to give structure to documents.
Add Windows Forms or WPF controls to the surface of a document to build interactive documents.
Application Level Add-Ins
Develop a managed add-in that users can use to interact with Word documents. An installed solution can operate on any open document.
Use automation to build an executable (external to Word) that can control Word, including starting Word, setting and getting ranges of text, saving the document, and more.
Use the altChunk functionality of Open XML to merge content from other Open XML documents, HTML documents, and more into a new document.
Business Data Connectivity Object Model
Connect to BCS data through SharePoint.
Custom XML Parts
Embed and associate XML documents in a word-processing document.
Document Level Customization
Develop a managed add-in that users can use to interact with Word documents. The solution is attached to a specific document or template.
Include a database file, such as a SQL Server Express (.mdf) file or a Microsoft Office Access (.mdb) file, in your Visual Studio Tools for Office solution.
Open XML SDK
Use the Open XML SDK to generate Word documents. In addition to generating documents, the Open XML SDK enables developers to make extensive modifications to a document such as replacing the contents of a paragraph.
Visual Basic for Applications
Use Visual Basic for Applications (unmanaged code) that is connected to and persisted with a specific document.
ActiveX Controls on Word Document
Use ActiveX controls on the surface of a document to create interactive documents.
ActiveX Controls on User Form
Use ActiveX controls on a user form to build interactive solutions.
Use unmanaged code to create a COM based add-in.
Customize command bars to enable users to carry out actions. Instead of using command bars, we recommend extending the ribbon.
Use XML to define custom task pane content that automatically synchronizes help, instructions, and programmable controls with the user's position in the document.
An actions pane is a customizable task pane that is attached to a specific Microsoft Office Word document in a document-level solution. It is hosted inside the Office task pane along with other built-in task panes. This real-estate can be docked to the right, bottom, left, or right of the document or spreadsheet. It can also be a floating window. You can use Windows Forms controls or WPF controls in an action pane.
SDK: Actions Pane Overview
How Do I: Use WPF Controls Inside an Excel Actions Pane?
MSDN: Features Available by Office Application and Project Type
Blog Post: Understanding the Difference between Custom Task Panes and Action Panes
You can add controls to your documents to create interactive documents, such as online forms. Instead of using ActiveX controls, Microsoft recommends using Windows Forms or WPF controls.
MSDN: Using ActiveX Controls on Word Documents
You can use ActiveX controls to create user forms. Instead of building user forms using ActiveX, Microsoft recommends building forms using Windows Forms or WPF.
MSDN: Effectively Using ActiveX Form Controls in Microsoft Word
MSDN: OLE Programmatic Identifiers
The altChunk functionality of the Open XML file formats enables easy merging of documents. You can merge content from multiple sources (other Open XML documents, HTML, plain text, and more) into a single document. After using the Open XML SDK to set up the document that imports alternative content, if you want to convert the document so that the new content is transformed to typical Open XML WordprocessingML, you need to open and save the document using Word 2010. Alternatively, you can use Word Automation Services to process the document and import the alternative content.
Blog Post: How to Use altChunk for Document Assembly
Blog Post: Comparison of altChunk to the DocumentBuilder Class
Blog Post: Formats Supported for altChunk
Blog Post: Inserting Content That Contains Images Using altChunk
Technical Article: Developing with SharePoint 2010 Word Automation Services
This type of add-in’s functionality is available regardless of which document, spreadsheet, or presentation is opened. An example of this variety is a department-wide or corporate-wide application that enables some level of functionality that every employee of the department or corporation needs to access on a regular basis. As an example, Lexis for Microsoft Office is an Office customization targeting legal firms. Users need to execute the same code for every document, so it is implemented as an application-level managed add-in.
MSDN: Office Development in Visual Studio
MSDN: Architecture of Application-Level Add-Ins
MSDN: Programming Application-Level Add-Ins
MSDN: Managing Task Panes in Multiple Word and InfoPath Documents
MSDN: Managing Custom Task Panes in Multiple Application Windows
MSDN: Expose an object in an application-level add-in to other Microsoft Office solutions.
SDK: Microsoft.Office.Interop.Word Namespace
Blog Post: Understanding the Three Approaches to Office Development
Word Automation is a technology where you can write a .NET application that uses the Word client executable to accomplish some task such as creating a document, querying a document for content, or modifying the content of a document. Its roots are COM – in addition to using .NET to link to the Primary Interop Assemblies, you can use C++ or VB6 (or any other technology that can consume COM) to automate the Word client application. In other words, you write a program that runs Word. There is a rich object model that you can use to manipulate paragraphs, ranges, comments, etc. This technology has been around for years. If you are an experienced Office developer who needed to generate a large number of documents (prior to the introduction of the Open XML SDK), then you have probably used Word Automation at one time or another.
The user operates a .NET managed application that in turn runs the Word 2007 or Word 2010 client.
Instead of generating word-processing documents using Word Automation, we recommend using the Open XML SDK together with Word Automation Services. The Open XML SDK and Word Automation Services are ‘server hardened’.
Blog Post: What is the Difference between ‘Word Automation’ and ‘Word Automation Services’?
Clicking the File tab takes you to the customizable Microsoft Office Backstage view. Backstage view helps you discover and use the features that fall outside the authoring features on the Ribbon. Ribbon, Mini toolbar and galleries all help you work in your documents; backstage view helps you work with your documents.
The following screen clipping shows the customizable backstage view.
Backstage View Developer Center
Technical Article: Introduction to the Office 2010 Backstage View for Developers
Technical Article: What's New for Developers in Office 2010
Technical Article: Customizing the Office 2010 Backstage View for Developers
Business Connectivity Services (BCS) brings line-of-business data into SharePoint 2010. SharePoint 2010 makes this data available to the Office client applications through the Business Data Connectivity Object Model (BDC OM). The following diagram shows how the Office clients (J) access BCS data through the BDC client runtime (K).
Business Connectivity Services Resource Center
TechNet: Business Connectivity Services overview
MSDN: Understanding Business Connectivity Services Client Cache to Optimize Your Solutions
MSDN: When Is the Cache Refreshed?
Blog: Overview of BCS Advanced Code-Based Solutions
You can build a Component Object Model (COM) Office add-in using C++, VB6, or other languages that can consume COM libraries. Microsoft does not recommend using COM extensions for new development. Microsoft does not recommend building COM based add-ins using C# or VB.NET. Instead, you should build an application-level add-in or a document-level customization using Visual Studio.
MSDN: Creating COM Add-ins in Office Developer
MSDN: Building COM Add-ins for the Visual Basic Editor
Office Online: Enable or disable add-ins in Office programs
The command bars object model exposes objects, collections, properties, and methods that you can use to show, hide, and modify existing command bars and command bar controls, and create new ones. In addition, you can specify a Microsoft® Visual Basic® for Applications (VBA) procedure to run when a user clicks a command bar button or to respond to events triggered by a command bar or command bar control. Instead of using command bars, Microsoft recommends extending the ribbon.
MSDN: Manipulating Command Bars and Command Bar Controls with VBA Code
How To Use Automation to Create Office Command Bars and Controls with Visual Basic .NET
Content controls are bounded and potentially labeled regions in a document that serve as containers for specific types of content. Using content controls in Word 2007 and Word 2010, you can create document templates with rich, structured blocks of content.
Word Content Controls Resource Center
How to: Add Content Controls to Word Documents
Walkthrough: Binding Content Controls to Custom XML Parts
Video: How Do I: Use Word Content Controls?
Visual How-To: Mapping Word 2007 Content Controls to Custom XML Using the XMLMapping Object
Customizing the context menu provides a convenient way for users to access functionality for your application-level add-in or document-level customization.
Technical Article: Customizing Context Menus in Office 2010
Custom task panes consist of screen real-estate that co-exists with the open document or spreadsheet within the Office client. This real-estate can be docked to the right, bottom, left, or right of the document or spreadsheet. It can also be a floating window. You can use Windows Forms controls or WPF controls in an action pane.
MSDN: Custom Task Panes Overview
Custom XML parts enable you to store arbitrary XML of your own design in the package of a document. The most common use for custom XML parts is to associate data in the parts with content controls in the document. However, you can use custom XML parts for any purpose that you like. For example, your managed add-in may need to keep some data for some important functionality. It can keep that data in a custom XML part, so that the data always accompanies the document.
Video How to: Binding Content Controls to Custom XML Parts
Blog Post: Creating Data-Bound Content Controls using the Open XML SDK and LINQ to XML
Using document-level customizations,.NET managed assemblies (code-signed for security purposes) are attached directly to each document, so if you send the document to a new user, they can open the document and use the custom functionality without explicitly installing an add-in. For example, a tax analysis department needs to systematically analyze documents for their tax implications and then communicate that analysis back to the document author. The result of that analysis is associated with a specific document, so it makes sense to build a document-level customization that manages the process of assessing and optimizing the tax implications of that document. A typical deployment might include an application-level add-in that is used by the tax analysis firm that produces a document that is customized with a document-level customization.
MSDN: Developing Document-Level Customizations for Word
MSDN: Architecture of Document-Level Customizations
MSDN: Cached Data in Document-Level Customizations
How Do I: Attach or Detach a VSTO Assembly from a Word Document?
Often in document management systems, users are asked—usually at the point when they are saving their documents—to provide metadata (properties) for their documents. Document information panels enable users to specify all the properties on a document at once, in one place, at any point when they are working with that document.
SDK: Document Information Panel Overview
You can include a database file, such as a SQL Server Express (.mdf) file or a Microsoft Office Access (.mdb) file, in your Visual Studio Tools for Office solution. This enables end users to maintain a local database in situations where maintaining a centralized database is not required, for example in a inventory solution where the data is embedded inside the document, and used on a single computer.
MSDN: Using Local Database Files in Office Solutions Overview
You can work directly with the Open XML file formats (DOCX, XLSX, and PPTX files) using the Open XML SDK. When you use the Open XML SDK, you are not directly customizing Microsoft Office, but are instead directly generating or modifying Office documents. The bulk generation of documents using the Open XML SDK is much faster than automating Word.
Open XML Developer Center
Blog: Eric White’s Blog
Blog: Zeyad Rajabi’s Open XML SDK Blog Map
The key benefit of customizing the ribbon is that it makes features of your application more discoverable. Users can see tabs that you add to the ribbon. They click on the tab, and then see buttons and other controls that help them understand the capabilities of your Office application.
MSDN: Ribbon Overview
How to: Get Started Customizing the Ribbon
Walkthrough: Creating a Custom Tab by Using the Ribbon Designer
Walkthrough: Creating a Custom Tab by Using Ribbon XML
Developers can create Word or Excel Smart Documents augmented with programmable pieces that help users create or modify them. Reusing boilerplate text, implementing business rules for how a document should be formatted or completed, and routing a document through an approval process are all procedures that Office Smart Documents can simplify.
Instead of using Smart Documents, we recommend building application-level or document-level managed add-ins.
MSDN Magazine: Create Word and Excel Smart Documents with C++ and XML
SDK: Smart Documents SDK
SDK: Understanding XML Expansion Packs
Office Online: About smart documents
You can add Windows Forms or WPF controls to the surface of a document, enabling richer interaction in the document for users. You can bind controls to data.
MSDN: Windows Forms Controls on Office Documents Overview
MSDN: Limitations of Windows Forms Controls on Office Documents
MSDN: Using Windows Forms Controls on Word Documents
MSDN: Binding Data to Controls in Office Solutions
How to: Populate Documents with Data from a Database
Visual Basic for Applications (VBA) is an implementation of Microsoft's event-driven programming language Visual Basic 6. Most Microsoft Office applications include an integrated editing and debugging environment for VBA. VBA enables developers to build user defined functions and automate processes that access the Word document and customize the user interface. Applications built with the 64-bit version of Office 2010 can reference larger address spaces, and therefore provide the opportunity to use more physical memory than ever, potentially reducing the overhead spent moving data in and out of physical memory.
Technical Article: Getting Started with VBA in Office 2010
Technical Article: Getting Started with VBA in Word 2010
MSDN: Signing a VBA Project
MSDN: Word Object Model Overview
Office online: Digitally sign a macro project
Technical Article: Compatibility Between the 32-bit and 64-bit Versions of Office 2010
MSDN: Interoperability between VBA and Visual Studio Tools for the Office System (3.0)
Great post Eric!
Do you know any easy way of making a choice(check box) field appear as a quick part in word using a content type?
Hello friends, I want to change the position of the keys on the keyboard to put the vouels and puntuation in left hand only, is this posible?
Who is the partner of BUILGATE or VULGATE or BUILDGATE (actually I didn't know the spelling of that name) in developing Microsoft Word or MS Word? Quick Answer please. . .
I want to find out how to use building blocks gallery controls for using contractual text. I'm a user and this page is aimed at programmers. Could we please have some advice for lay people. Help says that this functionality can be used but does not explain how.