Visual Studio 2010: Office Programmability

Version: 1.1.0

Description

In this lab you will see how new features in Visual Studio 2010, C# 4, and Visual Basic 10 make it easer to develop applications leveraging Microsoft Office. Additionally, you'll see a number of other powerful features which speed other elements of Office development.

Overview

Microsoft Office provides organizations an environment for rapidly creating business applications in an environment that is very familiar to end users. Building Office Business Applications present a large number of opportunities for organizations to take advantage of, including tying into Customer Relationship Management (CRM) systems, fronting data extracted from line of business applications, hosting business intelligence reports, and a wealth of other possibilities.

While Office development provides a great number of value opportunities for organizations, previously it also presented a number of challenges for developing and deploying those applications. Earlier versions of managed languages also contributed to the friction involved in creating applications using Office.

Calling numerous Office API methods was often painful due to the large number of parameters involved, many of which had no use. Visual Basic’s optional parameters feature made this easier, but developers in C# had to suffer through writing significant amounts of useless initializers or null statements to fill out required method signature parameters. If you were writing in Visual Basic, you had no access to an equivalent of C# 3.0’s lambda feature to supply inline methods when invoking delegates.

In this lab, you will see how new features in Visual Studio 2010, C# 4.0, and Visual Basic 10 eliminate the issues in the previous paragraphs. Additionally, you will see a number of other powerful features, which speed other elements of Office development.

Objectives

In this Hands-On Lab, you will learn how to:

  • Learn how new language features speed creation of business entities
  • Discover new language features that make it easier to have business entities interact with Excel
  • Utilize new language features which enable quick interaction between Office applications
  • See how the new build process allows easier deployment of Office applications to end users

System Requirements

You must have the following items to complete this lab:

  • Microsoft Visual Studio 2010
  • .Net Framework 4
  • Microsoft Excel 2007 or 2010
  • Microsoft Word 2007 or 2010

Setup

All the requisites for this lab are verified using the Configuration Wizard. To make sure that everything is correctly configured, follow these steps:

Note:
To perform the setup steps you need to run the scripts in a command window with administrator privileges.

  1. Run the Configuration Wizard for the Training Kit if you have not done it previously. To do this, browse to Source\Setup folder of this lab, and double-click the Dependencies.dep file. Install any pre-requisites that are missing (rescanning if necessary) and complete the wizard.

    Note:
    The Configuration Wizard is used for checking dependencies and setting up the environment. If the Configuration Wizard is not installed on your machine, you must install it running the DependencyChecker.msi file located on the %VS2010TKInstallationFolder%\Assets\DependencyChecker folder (e.g. by default the Training Kit is installed under C:\VS2010TrainingKit).

    For convenience, much of the code you will be managing along this lab is available as Visual Studio code snippets. The Dependencies.dep file launches the Visual Studio installer file that installs the code snippets.

Exercises

This Hands-On Lab is comprised of the following exercises:

  1. Creating a collection of account classes and display the account information in Microsoft Excel
  2. Embed the Microsoft Excel worksheet in a Microsoft Word document
  3. Alter the VS project files to enable the program to be deployed without PIA

Estimated time to complete this lab: 60 minutes.

Next Step

Exercise 1: Creating a Collection of Business Entities and Inserting their Values into an Excel Worksheet