Building Office Business Applications Using Visual Studio Tools for the Office System (3.0)
Summary: This article shows how to take advantage of Visual Studio 2008 to easily build and deploy customized Office Business Applications. (12 printed pages)
Erika Ehrli Cabral, Microsoft Corporation
Steve Fox, Microsoft Corporation
Applies to: Microsoft Visual Studio 2008, Microsoft Visual Studio Tools for the Microsoft Office System (3.0), 2007 Microsoft Office system, Microsoft Office SharePoint Server 2007, Windows SharePoint Services 3.0
Evolution of Visual Studio Tools for Microsoft Office and Office Development
Developers have created applications for Microsoft Office for some time but with Microsoft Office 2003, Microsoft Office emerged as a first-class developer platform.
Before Microsoft Office 2003, Office development was limited to automating repetitive tasks through custom macros with Microsoft Visual Basic for Applications (VBA) and to building custom COM add-in solutions by using Microsoft Visual Studio 6.0 or Microsoft Visual C++. However, the Microsoft .NET Framework and the Microsoft Office primary interop assemblies enable you to build custom add-ins and smart client solutions by interacting with an Office application's COM-based object model using managed code. For more information, see Office Primary Interop Assemblies.
Complex and time-consuming, this early interoperability was limited to client-side development since Office automation is not supported for server-side scenarios. Microsoft Visual Studio Tools for Office, Version 2003 introduced new possibilities to Office Development. The 2007 Microsoft Office system release further expanded the variety of custom solutions that you can create. The 2007 release represents a true development platform that consists of applications, servers, services, and tools that together enable you to bridge the information gap between users and data in line-of-business (LOB) enterprise systems. Later releases of Visual Studio Tools for Microsoft Office continued to expand development opportunities. For more information, see What's New in Visual Studio Tools for Office.
The following table lists the features available to Microsoft Office developers according to each release of Visual Studio Tools for Microsoft Office, including the supported Microsoft Office applications
Table 1. Features by Visual Studio version
Microsoft Visual Studio 2005 Tools for the Microsoft Office System
Microsoft Visual Studio 2005 Tools Second Edition for the 2007 Microsoft Office System, Second Edition
Microsoft Visual Studio Tools for the Microsoft Office system (3.0)
Office Business Applications: a New Breed of Office Applications
Office Business Applications are a new breed of applications that use the Microsoft Office system to find and surface LOB information. Office Business Applications help you extend Microsoft Office clients and servers into business processes running in LOB systems that support Enterprise Resource Planning (ERP), Customer Relationship Management (CRM), and Supply Chain Management (SCM). This enables enterprises to get new value from existing IT investments by combining them in innovative ways. For more information see, Getting Started with Office Business Applications (Part 1 of 2).
The 2007 release of Microsoft Office embraces open XML standards to enhance collaboration and interoperability across applications and organizations. With the adoption of open standards-based technology, Microsoft Office replaces the proprietary binary formats used in previous versions with an open, fully documented, royalty-free format that is based on industry XML and ZIP standards. The 2007 Office system also significantly improves productivity with the new Microsoft Office Fluent interface.
Server-side application development benefits from the use of the shared workspaces available in Microsoft Office SharePoint Server 2007. This helps information technology (IT) departments to collaborate over corporate boundaries. For more information on the different products and technologies that compose the 2007 Microsoft Office system, download the Microsoft Office Interactive Developer Map.
More than a wide variety of programs, server, services, tools, and technologies, the 2007 Microsoft Office system is a unified solutions platform for building Office Business Applications that makes LOB applications, enterprise data, and workflows accessible and relevant to users.
Introducing the Business Productivity Infrastructure
The 2007 Microsoft Office system and Office Business Applications services help meet the demands of the industry by providing an integrated approach to unified communications, business intelligence, enterprise content management, collaboration, and enterprise search.
Figure 1. Business productivity infrastructure
Key Platform Capabilities
Key platform capabilities such as an extensible user interface, Open XML File Formats, Web site and security framework, workflow, search, and the business data catalog enable Office Business Applications services. The following section provides a high-level overview of key platform capabilities and provides pointers to related resources.
Extensible User Interface
The Microsoft Office Fluent UI replaces the previous system of layered menus, toolbars, and task panes with a simpler system optimized for efficiency and discoverability. The Office Fluent UI, including the Ribbon, provides improved context menus, enhanced screen tips, a mini toolbar, and keyboard shortcuts that help to improve user efficiency and productivity.
The Office Fluent UI is implemented in Microsoft Office Access 2007, Microsoft Office Excel 2007, Microsoft Office Outlook 2007, Microsoft Office PowerPoint 2007, and Microsoft Office Word 2007. You can add custom tabs with controls, including buttons, list boxes, and galleries. In addition, you can integrate commands into existing tabs and context menus. You can use markup and managed or unmanaged code to customize the Fluent UI. For more information, see the Office Fluent User Interface Developer Portal.
Open XML File Formats
The Office Open XML Package specification defines a set of XML files that contain the content and define the relationships for all of the parts stored in a single package. These packages combine the parts that make up the document files for Excel 2007, PowerPoint 2007, and Word 2007. Compact, robust file formats enable better data integration between documents and back-end systems. An open, royalty-free file format specification maximizes interoperability in a diverse environment, and enables any technology provider to integrate Microsoft Office documents into their solutions. It also helps deliver server-side document generation solutions. You can use the Open XML Object Model API to create documents programmatically. For more information, see the Office Open XML Formats Resource Center.
Web Site and Security Framework
Microsoft Office SharePoint Server 2007 builds upon the Windows SharePoint Services 3.0 infrastructure to provide an enterprise portal platform. Together they provide a common site framework for all types of Web sites including intranet, extranet, and Internet. SharePoint Products and Technologies provide a secure platform by integrating with Internet Information Services (IIS) and Windows to provide authentication and authorization mechanisms. You can use multiple APIs and Web services to customize and extend SharePoint Products and Technologies. For a complete list of Microsoft Office SharePoint Server classes and namespaces, see the Class Library of the Microsoft Office SharePoint Server 2007 SDK.
Windows SharePoint Services 3.0 and Microsoft Office SharePoint Server 2007 provide a new platform for defining and running workflows such as document-approval and issue tracking. The workflow platform is implemented on top of the Windows Workflow Foundation, a Windows platform component that provides a programming infrastructure and tools for development and execution of workflow-based applications. You can use the Workflow object model to query and manage workflows programmatically. For more information, see the Workflow Information Center.
SharePoint Products and Technologies incorporate enterprise content such as people and business data, along with documents and Web pages, to provide more comprehensive search results. This extensible solution provides a consistent and familiar search experience that incorporates enterprise content, people and expertise, and data from line-of-business applications. You can extend and create custom search queries programmatically using the Enterprise Search Query Object Model. You can also use the Enterprise Search Administration Object Model to create custom applications to administer enterprise search programmatically. For more information, see the Enterprise Search Information Center.
Business Data Catalog
Microsoft Office SharePoint Server 2007 provides a new business integration feature and shared service that helps reveal business data from back-end server applications. It provides built-in support for displaying data from databases and Web services. That is, you can use the business data catalog to display data from your SAP, Siebel, or other LOB system by using Web services or databases. Therefore, it helps bring key data from different business applications to SharePoint lists, Web Parts, search, user profiles, and custom applications. You can use the Business data catalog metadata model to define a line-of-business entity and the Administration Object Model to manage metadata programmatically. For more information see the Business Data Catalog Information Center.
2007 Microsoft Office System Investments
You can use the platform capabilities to extend Microsoft Office system investments in business intelligence, unified communications and collaboration, and enterprise content management, as well as other business applications by ISVs or corporate developers.
Unified Communications integrates Microsoft Office Communications Server 2007, Microsoft Exchange Hosted Services, Microsoft Office Outlook 2007, Microsoft Office Communicator 2007, Microsoft Exchange Server 2007, and Microsoft Office Live Meeting service to provide a complete and affordable solution. These solutions include e-mail/calendaring, mobile messaging and device management, unified messaging, presence/instant messaging, VoIP call management, audio/video/Web conferencing, and security services. For more information, see the Unified Communications Developer Portal.
Enterprises gather data related to LOB operations. Data as-is is not useful. You need to transform it into information so you can understand your business and make decisions. This includes reporting, analysis, performance management, and data warehousing technologies that improve business insight and drive business performance. The 2007 Office system allows you to deliver business intelligence solutions by extending programs, creating server-side solutions or by using Performance Point Server 2007 to model performance management applications. For more information, see the PerformancePoint Server Developer Portaland the Excel Services Information Center.
Enterprise Content Management (ECM)
Enterprise content management is a key infrastructure component that can help companies to manage and organize high volume of unstructured content that includes forms, documents, records, e-mail messages, videos, instant messages (IMs), Web pages, and more. Office SharePoint Server 2007 provides Web content management technologies that streamline the management of content and process. For more information, see the Enterprise Content Management Information Center.
SharePoint Products and Technologies provide a platform that enables people to mange their communications and collaboration more effectively. This includes pervasive collaborative workspaces, a robust portal framework and set of social computing tools. Office SharePoint Server 2007 and Microsoft Groove Server 2007 provide collaborative workspaces to facilitate collaborative project and task management. SharePoint Products and Technologies also provide the platform to build workflow projects that help build collaborative solutions. These products and technologies facilitate the access to people and information and people-driven processes. For more information, see the Office Groove 2007 Developer Portal.
Enterprises manage and organize high volumes of information, documents, and Web pages. Enterprise search solutions bring together desktop and business search applications that use the same pedigree of indexing and query engines. This enables common functionality and extensibility between the applications that use it. Search applications and add-ins built for Office SharePoint Server 2007 are often reused for Windows Vista with little or no change. This includes different Search technologies that empower your people to find the information and expertise they need to drive results. For more information, see the Enterprise Search Information Center.
Benefits of Visual Studio Tools for the Office System (3.0)
Visual Studio Tools for the Office system (3.0) is the key developer technology that enables you to create scalable, LOB solutions for Microsoft Office by using the Office development features included with Visual Studio 2008. It provides rapid application development that includes visual designers that auto generate code and provides first-class project templates. You can use existing programming skills and legacy Microsoft Office solutions. Along with SharePoint Products and Technologies, it is one of the primary tools used to create and extend Office Business Applications. Building Office Business Applications you can streamline common tasks and business processes, simplifying how users access and work with back-end enterprise data and services.
Figure 2 Value proposition offered by Visual Studio 2008 and Visual Studio Tools for Office 3.0
What's New for Developers in Visual Studio Tools for Office 3.0
Visual Studio Tools for the Office system (3.0) provides a rich set of features with which to build and deploy customized Office Business Applications. It provides a set of workflow projects templates that help build collaborative solutions. The following section provides a high-level overview of key additions.
As a fully integrated component of Visual Studio 2008, Visual Studio Tools for the Office system (3.0) offers wider support for application-level add-ins and document-level solutions in the 2003 Office release and the 2007 Office release. This gives you more flexibility in the types of projects you can develop as well as Microsoft Office applications to program against.
Figure 3. New project templates in Visual Studio 2008.
Another exciting feature within Visual Studio 2008 is the support for Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF) and Language Integrated Query (LINQ). This means that you can now build Microsoft Office solutions with improved graphical presentation and data visualization, more secure connections to custom services and build LINQ into applications where you may use SQL statements today. Custom Ribbon elements not only extend your applications, but keep your information workers in the context of an environment that is comfortable and familiar.
Figure 4. Custom task pane and Office Fluent Ribbon with formatted data
Visual Ribbon Designer
Using Visual Studio Tools for the Office system (3.0), you can create document-level customizations and application-level add-ins and customize the Office Fluent UI of the following applications:
Office Excel 2007
Office Outlook 2007
Office PowerPoint 2007
Office Word 2007
Figure 5. Office Fluent Ribbon UI Extensibility including groups and controls
Visual Studio 2008 provides a Visual Ribbon Designer that helps simplify the task extending the Office Fluent UI. You can drag and drop controls from the toolbar to the design surface and customize properties using the properties grid.
Figure 6. Visual Ribbon design surface with control toolbox and the property grid
Using the Visual Ribbon Designer, you can create groups, tabs, and commands using a design view. Follow the same approach you use to design Windows Forms applications using the controls that appear on the toolbox and the properties grid. You can then add event handlers to the control to build custom business logic into your customization. This simplifies extending the Office Fluent UI. You can:
Add new functionality to existing Office Fluent Ribbons by overriding or extending the existing UI
Customize existing tabs
Add to built-in tabs
Remove tabs, groups, and controls
Additionally, you can always access the code-behind to programmatically customize and extend the behavior of the Office Fluent Ribbon controls.
You can also use XML markup to customize the Office Fluent UI. Visual Studio Tools for the Office system (3.0) provides built-in support for XML-based customization model. It provides an Export to XML option that simplifies generating custom markup for the Office Fluent UI.
For more information, see the following videos:
Office Ribbon Customization in Visual Studio 2008
Using the Ribbon Designer in VSTO
Data Binding with Word 2007 Content Controls
Customizing document templates and connecting them to LOB data through data binding is a common business need. Imagine that you work for a sales company that needs to print large volumes of invoices and you must programmatically generate invoices based on data stored on a Microsoft SQL Server 2005 repository.
Content controls in Office Word 2007 provide an easy way to create blocks of content, such as combo boxes, that are more secure from accidental modification by end users. After you add content controls, you can use XML mapping to map content controls to data from custom XML to the document.
Figure 7. Sample sales invoice document template that uses content controls
You can add content controls and VBA code to map regions of a document template with LOB data stored in a custom xml file. For more information, see Building Word 2007 Document Templates Using Content Controls.
Visual Studio Tools for the Office system (3.0) provides a new option for developing structured documents in Word 2007. You can drag and drop Word 2007 content controls directly from the toolbox in Visual Studio. You can also access the properties and events of content controls using the property grid. Figure 8 shows the Word content controls toolbox, the property grid, and the data sources window.
Figure 8. Customizing Word 2007 content controls in Visual Studio 2008
Programmatic access to LOB data through Word object model support for XML mapping simplifies the programming paradigm. Visual Studio provides support for Microsoft IntelliSense for content control programming. The experience follows the Windows Forms programming model. You can generate event handling by double-clicking the controls.
Data binding is also simpler. You have two different options to map content controls to business data:
Drag and drop from Data Sources window. You can use the Data Sources view in Visual Studio 2008 to define the mapping between content controls and fields from a custom data source.
Set up through the property grid. You can use the property grid in Visual Studio 2008 to define the 1 to 1 mapping between a content control and a custom data source.
For more information see, Binding Data to Word 2007 Content Controls Using Visual Studio Tools for the Office System (3.0).
Custom Outlook Form Regions
More than a product to manage e-mail, calendar, contacts, and tasks, you can use Outlook 2007 as a presentation layer for custom applications. Solution developers frequently need to pull LOB data and expose approval forms that allow users to make decisions and interact with business processes. Instead of having the users to go to yet another system, you can use Outlook as an application UI.
Outlook 2007 introduced a new form technology called Outlook form regions, which you can use to replace the built-in forms. You can extend forms and add additional fields or controls in a variety of new ways. You can display forms on a Reading pane, use adjoining form regions, or separate form regions to extend the UI in Outlook 2007. To do this, you need to implement a COM add-in and write a form region manifest. For more information, see Building an Outlook 2007 Form Region with a Managed Add-In.
Figure 9. Custom forms region solution for interacting with LOB data
The Outlook Forms Designer in Visual Studio Tools for the Office system (3.0) simplifies implementing Outlook form regions. You can create custom solutions using four different types of form regions:
Adjoining and separate regions for custom message classes
Adjoining and separate regions for built-in forms
Replacement regions for custom message classes
Replace-all regions for custom message classes
The Reading pane can display all types except separate.
Additionally, new controls enable data binding to Outlook data.
You can use a wizard to import Outlook-designed form regions. The wizard helps create controls and associates them with the correct name and types. Visual Studio Tools for the Office system (3.0) enables Windows Forms regions created by using the Windows Forms designer. This provides drag-and-drop functionality for controls from the toolbox and properties grid support.
Visual Studio Tools for the Office system (3.0) provides an enhanced programming model, form region manifest object, and automatic registration of add-in and form region. Code-behind form region is implemented as a COM add-in.
For more information, see Creating Outlook 2007 Form Regions Using Visual Studio Tools for the Office System (3.0).
Workflow Support and Support for SharePoint Products and Technologies
Using workflows, you can streamline business processes and route specific tasks to different actors and systems. Combined with software, enterprises can simplify and optimize workflows.
The Windows Workflow Foundation, Windows SharePoint Services 3.0, and Office SharePoint Server 2007 are designed to help create workflow solutions. You can use Microsoft Office SharePoint Designer and Microsoft Visual Studio 2005 to build custom workflow solutions. However, creating custom workflow solutions using these techniques are lengthy, error-prone, and limiting.
Visual Studio Tools for the Office system (3.0) supports the creation of SharePoint workflows to help manage business process and information flow. It reduces complexity and speeds development of SharePoint workflows.
Using Visual Studio Tools for the Office system (3.0), you can build either sequential or state-machine workflow solutions by:
Creating a custom workflow layout
Adding custom code to the workflow
Adding tasks to workflow
Adding custom forms to the workflow
One of the most important enhancements is the use of wizards to simplify creating and deploying workflow solutions. You can associate workflows with SharePoint libraries and focus on designing the actual workflow and the solution. Figure 10 shows the Start New Workflow wizard and the integration of custom workflows initiation with Microsoft Office.
Figure 10. Initiation of custom workflow solutions from Microsoft Office
For more information, see SharePoint Workflow Templates Solutions.
Interoperability with VBA
One of the biggest challenges for organizations is migrating existing VBA solutions to managed code. Existing Office solutions may benefit from the latest features and enhancements added to the latest versions. However, migrating solutions represents a big investment for companies.
One of the most significant enhancements that can impact organizations is the interoperability between VBA and Visual Studio Tools for the Office system (3.0).
This interoperability enables you to discover and call managed code from within VBA macros. It also helps preserve your investment in VBA by helping you to add new functionality to existing VBA applications. Supported in Word 2007 and Excel 2007, Visual Studio Tools for the Office system (3.0) enables incremental extension of VBA solutions by using Visual Basic or C#.
You can also enable VBA interoperability using COM interop at design-time. The support for Microsoft IntelliSense is another huge advantage. It works within the VBA editor and helps you discover and call managed code as shown in Figure 11.
Figure 11. Calling managed Visual Basic code from VBA
Activating interoperability in a Microsoft Visual C# project is more complex.
For more information, see VBA Interoperability with Visual Studio Tools for the Office System (3.0).
Improved Deployment and Security by Using ClickOnce
Visual Studio Tools for the Office system (3.0) also introduces ClickOnce technology to Microsoft Office development. ClickOnce enables easy and efficient deployment of solutions.
When developing solutions using Visual Studio Tools for the Office system (3.0), you build a managed code assembly that is an application-level add in or a document-level customization such as a document template. In either of these cases, with ClickOnce, you can build and publish the set-up files locally, remotely, or to a CD to provide maximum flexibility. This new feature also deploys your customizations by default in full trust, so you do not have to configure applications with the Code Access Security Policy tool or other special security protocols. After deployment, each time the user invokes the add-in or solution, it automatically checks for updates to ensure the user always has the latest managed code assembly in their environment.
Figure 12. Publish wizard in Visual Studio 2008
The 2007 Microsoft Office system is a unified solutions platform for building Office Business Applications that make line-of-business applications, enterprise data, and workflows accessible and relevant to users. Visual Studio Tools for the Office system (3.0) is the key developer tool technology to help you create scalable, LOB solutions for the Microsoft Office system.
For more information, see the following resources: