Microsoft Office Excel Programming Using VSTO 3.0

Exclusive offer: get 50% off this eBook here
VSTO 3.0 for Office 2007 Programming

VSTO 3.0 for Office 2007 Programming — Save 50%

Get to grips with Programming Office 2007 using Visual Studio Tools for Office

€16.99    €8.50
by Vivek Thangaswamy | March 2009 | Microsoft

Beginning with programming in Excel 2007 using VSTO 3.0 and proceeding with programming concepts, we are going to learn how to manipulate data inside Excel. Later, you will learn the concepts of workbook manipulation and worksheet manipulation, with code samples. When programming in the Excel 2007, the object model plays an important role. You will learn the most important and widely used objects, with the help of demonstrations.

In this article by Vivek Thangaswamy, we will take a look at the following:

  • Excel 2007 in Visual Studio 2008, including how to start an Excel solution in Visual Studio 2008
  • Excel 2007 solution: the object model, and the object model functional area
  • Data and worksheet manipulation in Excel 2007
  • Data processing with Microsoft SQL Server 2008

Microsoft Office Excel is the most frequently-used Microsoft application and one of the leading spreadsheet programs available. A spreadsheet program is a program that uses a huge grid to display data in rows and columns. The spreadsheet program can then be used to do calculation, data manipulation, and various similar tasks, against this data.

Programming in Excel

Microsoft Office Excel is one of the powerful Office tools that provides uncomplicated data management. It is loaded with features such as graphing, charting, pivot tables, and calculation. Even though Excel is loaded with numerous features for users, there may be some functionality that cannot be achieved by using the standard Microsoft Excel environment. In Microsoft Office Excel 2007, automation is a great mechanism for populating business documents (for example, reports) with data from backend system. This can be achieved by using VSTO 3.0 and Visual Studio 2008. Microsoft Office Excel 2007 is more programmable than ever before with support for Visual Studio Tools for Office.

VSTO is aimed at Microsoft Office Excel users who want to develop Excel-based applications for other Microsoft Office Excel users. VSTO 3.0 is shipped with all of the newly-enhanced Excel objects, including improved features for building Microsoft Office based solutions.

VSTO 3.0 is loaded with new features, including support for Windows form controls from within Microsoft Office tools customization. It provides the support for using .NET frameworks, objects and classes for Microsoft Office tools customization. For example, System.Data is the .NET frameworks object that can be used inside the Excel solution to process database operations. This new feature is tightly integrated with the Visual Studio 2008 IDE and gives you the comfort of design time customization of Excel documents for data display and UI customization.

Similar to other Microsoft Office Tools, with Microsoft Office Excel 2007 customization using VSTO 3.0, you have two levels of customization— document-level customization and application-level customization. Document-level customization is a solution created for document-level programming and is specific to the document that is part of that particular solution. Application-level customization is a solution created for application-level programming and is specific to the application, and therefore common to all documents based on that application.

In a simple Hello World demonstration, let's learn about the document level customization approach. We'll step through a simple task, showing how to create an Excel document that will display a Hello World message on startup.

Hello World example using Visual Studio 2008

  1. Open Visual Studio 2008, and create a new Excel 2007 Workbook project.
  2. Select New Project. Under Office select 2007, and then select the Excel 2007 Workbook template and name the project ExcelHelloWorld, as shown in the following image:

    VSTO 3.0 for Office 2007 Programming

  3. The document selection dialog box is displayed. At this point, you need to choose the template for your design. In this example, you select a new blank template and click on the OK button. Refer to the following screenshot:

    VSTO 3.0 for Office 2007 Programming

    The solution will be created with all of the supporting files required for our development of an Excel solution. Each solution is created with three worksheets, with default names: Sheet1, Sheet2, and Sheet3 for the workbook you're going to customize , as shown in the following image. The number of sheets in a new workbook depends on the settings in Excel. The following image also shows you the Excel-supported controls, placed on the leftmost side of the Visual Studio 2008 toolbox panel. You can also see the visual representation of Excel 2007 inside Visual Studio 2008.

    VSTO 3.0 for Office 2007 Programming

  4. Let's write our Hello World message in a cell when we load the Excel 2007 document. Write the following code inside the ThisWorkbook.cs file.
    // The Startup event of workbook in our Excel solution
    // Startup event common to all Office application
    // Startup event will be fired at the start of the application
    private void ThisWorkbook_Startup(object sender,
    System.EventArgs e)
    {
    // Creating the instance of active WorkSheet of Excel Document
    Excel.Worksheet AuthorWorkSheet = ThisApplication.ActiveSheet
    as Excel.Worksheet;
    // Get the range using number index through Excel cells
    by setting AuthorExchange to an Excel range object starting at
    (1,1) and ending at (1,1)
    Excel.Range AuthorExcelRange = ThisApplication.
    get_Range(AuthorWorkSheet.Cells[1, 1],
    AuthorWorkSheet.Cells[1, 1]);
    // Setting the value in the cell
    AuthorExcelRange.Value2 = "Hello! this is my VSTO program for
    Excel 2007";
    }

    The following screenshot results after adding and executing the preceding code:

    VSTO 3.0 for Office 2007 Programming

Manipulation

Microsoft Office Excel is one of the most comprehensive data management tools for all kinds of users. It is a tool that can be easily understood and quickly learnt. The most important feature of Microsoft Office Excel is its capability to manipulate data from different sources.

Excel is one of the most powerful and user-friendly data manipulation applications. You could use Excel to predict what's ahead for your business by creating detailed financial forecasts. This powerful application has pivot table functionality that allows you to drop in your data and rearrange it to answer all kinds of business data analysis type questions. Excel helps you to build various useful analytical tools such as your monthly sales report and product sales growth analysis more easily and flexibly. Excel offers you formulae and functions that will help you to perform complex financial calculations without any manual errors. Excel can provide you with a graphical presentation of your business data by using charts and graphs.

Want to know your growth levels for a specific product sales range? Check which parts of your business are performing worse? The pivot table provides more information from your business in depth.

Every application in this computer world works with data. The data can be in any form and can belong to different sources. The key question for data management is where to place the data. You manage the data in two ways: data managed outside the program and data managed inside the program. The data managed outside the program includes data managed in a database, a file system, and so on. Data managed inside the program includes data in different worksheets within the workbook, embedded images, and so on.

Data manipulation

For users who are not satisfied with the default features in Microsoft Office Excel, VSTO programming makes Excel more flexible, and provides a development tool for the creation of custom solutions for data manipulation and data analysis.

Custom programming using VSTO 3.0 improves most part of the Microsoft Office Excel solution. Custom programming using VSTO 3.0 provides a wide range of advantages, including saving time by automating most of the frequently-performed tasks, reducing errors due to manual operations, as well as enforcing standards for data processing, and building the capability to seamlessly integrate with other applications seamlessly.

Reading worksheet cells

There are many ways to manipulate data and write to the cells in an Excel worksheet. Let's see some of these ways. We can read worksheet cells directly through the Cells property of the sheets, rows, and columns, and can set a value directly by using the cell's row and column index. Open Visual Studio 2008 and create a new Excel solution. Refer to the previous example for full instructions of how to do this. Write the following code inside the ThisWorkbook.cs file. In this sample explanation, you are writing data into the worksheet by using the Cells object.

// The Startup event of workbook in our Excel solution
private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// Set value for Cells row and column index
// Text data in Sheet1 cells
Globals.Sheet1.Cells[3, 3] = "Set my data";
}

We can also read the worksheet and write data to the cells by using the Range object. In this case, you are creating the range and setting the text data for the range in the Excel worksheet.

Open Visual Studio 2008 and create a new solution, as before. Write the following code inside the ThisWorkbook.cs file . In this demonstration, you read the worksheet through the range of cells and set the value by reading through cell ranges.

private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// Setting value in ExcelSheet cells through reading range object
Excel.Range AuthorExcelSheetRange = Globals.Sheet1.Range["A2",
"B2"];
// Text data for the range A2 to B2
AuthorExcelSheetRange.Value2 = "Set my data";
}

Let's see a demonstration of how to read data from an external data file and display this inside our Excel cells. In this demonstration, you will see how the data from the text (.txt) file is displayed in the spreadsheet.

Opening a text file as a workbook using VSTO

We'll now see how to open the text file as a workbook by using VSTO and C# programming. This saves time and makes the user more comfortable in accessing the text file while processing the data. Open Visual Studio 2008 and create a new solution, as before. Write the following code inside the ThisWorkbook.cs file:

// Opening Text file as workbook
private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// In the workbook objects, file path as parameter in Opentext
property this.Application.Workbooks.OpenText(@"C:TechBooks.txt",
// Value 1 is, the row from which it will read data in the text
file missing, 1,
// Checks for delimits for text parsing
Excel.XlTextParsingType.xlDelimited,
// Text Enumeration value
Excel.XlTextQualifier.xlTextQualifierNone,
missing, missing, missing, true, missing, missing, missing,
missing, missing, missing, missing, missing, missing);
}

Connecting with Microsoft SQL Server 2008 database

Microsoft SQL Server 2008 is a relational database management system developed by Microsoft Corporation. Microsoft SQL Server is used to manage a huge volume of data along with relation and Metadata information for this data. VSTO provides support for manipulating the data from your database inside Excel using ADO.NET classes.

VSTO 3.0 for Office 2007 Programming

The preceding figure demonstrates how an Excel 2007 object is used to interact with the Microsoft SQL Server database. Let's see how to connect with a relational database management system, retrieve data from the database, and finally display it in our Excel spreadsheet. This demonstration shows you how to retrieve data from a Microsoft SQL Server 2008 database and place the retrieved data into the worksheet cells.

Open Visual Studio 2008 and create a new solution, as usual. Write the following code inside the ThisWorkbook.cs file.

// Namespace for SQL Server connection
using System.Data.SqlClient;
// Startup event of the workbook
private void ThisWorkbook_Startup(object sender,
System.EventArgs e)
{
// Opening SQL connection for Microsoft SQL Server 2008
// WINNER the database server contains the databse called Products
SqlConnection MySQLConnection = new SqlConnection(@"Data
Source=WINNER;Initial Catalog=Products;
Integrated Security=True");
// Passing SQL command text
SqlCommand MySQLCommand = new SqlCommand("SELECT * FROM
Books", MySQLConnection);
MySQLConnection.Open();
// SQL reader to read through data from Database
SqlDataReader MySQLReader = MySQLCommand.ExecuteReader();
// Get the active sheet of current application
Excel.Worksheet MyWorkSheet = this.Application.ActiveSheet as
Excel.Worksheet;
// Header for the columns set in the Value2 properties
((Excel.Range)MyWorkSheet.Cells[1, 1]).Value2 = "Book Name";
((Excel.Range)MyWorkSheet.Cells[1, 2]).Value2 = "Author Name";
// Indexer
int i = 2;
// Loop to read through the database returned data
while (MySQLReader.Read())
{
// Writing the data from the database table column BookName
((Excel.Range)MyWorkSheet.Cells[i, 1]).Value2 =
MySQLReader["BookName"];
// Writing the data from the database table column Author
((Excel.Range)MyWorkSheet.Cells[i, 2]).Value2 =
MySQLReader["Author"];
i++;
}
// Dispose the SQL command
MySQLCommand.Dispose();
// Closing SQL connection after using it.
MySQLConnection.Close();
}

The following screenshot displays data retrieved from Microsoft SQL Server 2008 database and the data being displayed in the worksheet cells.

VSTO 3.0 for Office 2007 Programming

In this demonstration, you learned how to connect with a Microsoft SQL Server 2008 database in order to get data and populate it in a workbook. This is just one of the ways of manipulating data outside of a workbook.

VSTO 3.0 for Office 2007 Programming Get to grips with Programming Office 2007 using Visual Studio Tools for Office
Published: March 2009
eBook Price: €16.99
Book Price: €26.99
See more
Select your format and quantity:

Worksheet manipulation

A Microsoft Excel file is represented in Excel as a workbook. Each and every workbook can have many worksheets. Worksheets are individual data grids within the workbook. The term 'worksheet' refers to the rows and columns of the sheet on which you are working, whereas the term 'spreadsheet' refers to a type of computer application.

VSTO helps you to manage Excel worksheets programmatically. Using VSTO's programming support, you can access worksheets, add worksheets, delete worksheets, and so on.

Open Visual Studio 2008 and create a solution with all the supporting files for the development of the Excel solution. Write the following code inside the ThisWorkbook.cs file. Here, you're going to add and delete worksheets within your workbook, at runtime, using the VSTO programming.

  • Code for adding a worksheet to your workbook using VSTO:.
    private void ThisWorkbook_Startup(object sender,
    System.EventArgs e)
    {
    // Adding worksheet to our workbook
    Excel.Worksheet AuthorWorksheet = Sheets.Add (missing,
    missing, 1, missing) as Excel.Worksheet;
    }
  • Code for deleting a worksheet from a workbook using VSTO:
    private void ThisWorkbook_Startup(object sender,
    System.EventArgs e)
    {
    // Code to delete the second sheet, referenced here as Sheets[2]
    because we have not turned off the DisplayAlerts flag, a
    warning message will be prompted before deleting
    which causes a stop in the automated solution that requires
    user input
    ((Excel.Worksheet)this.Application.ActiveWorkbook.
    Sheets[2]).Delete();
    }

The following screenshot shows how the code tries to delete the worksheet and how the Excel application prompts the user to confirm the deletion.

VSTO 3.0 for Office 2007 Programming

The following programming tip will help you to avoid seeing the delete warning message that is displayed to the user when deleting the worksheet.

// To avoid warning messages
this.Application.DisplayAlerts = false;
// The code will delete the second sheet.
((Excel.Worksheet)this.Application.ActiveWorkbook.Sheets[2]).
Delete();

Worksheet manipulation helps document users to provide better data processing. It is advantageous as it has easy access to data, builds better user interfaces, and optimizes data processing for reports and other business needs.

Working with ranges

Microsoft Office Excel is loaded with a wide variety of objects that can be programmed for using VSTO 3.0. The Range object is probably the most frequently-used object in the Excel object model, and helps an Excel developer to manipulate the cells and their data by using a referenced range. In this section, we will see how to refer to cells programmatically, and manipulate the ranges of data in Microsoft Office Excel 2007. The Excel range is a vital part of the Excel application. A range may correspond to a logical relationship between cells.

The following sample program explains how to read the cells of a worksheet by using the Range object, and how to format the background color of a range of cells.

Open Visual Studio 2008 and create a new solution, as before. Write the following code inside the Sheet1.cs file.

private void Sheet1_Startup(object sender, System.EventArgs e)
{
// Reading Excel using Range object
Excel.Range AuthorRange = Globals.Sheet1.Range["A1", "C5"] as
Excel.Range;
// Formatting the selected Range with autocolor format
AuthorRange.AutoFormat(Excel.XlRangeAutoFormat.
xlRangeAutoFormatColor1, true, false, true, false,
true, true);
}

Adding and executing the preceding code results in the following screenshot:

VSTO 3.0 for Office 2007 Programming

Cells

In any spreadsheet program, such as Microsoft Office Excel, each rectangular box is referred to as a cell. A cell is the intersection point of a column and a row inside the spreadsheet. Using VSTO, you can manipulate the cells in the worksheet for processing data in the worksheet. You can apply formulas, add smart tags, and merge and format cells, depending on conditions.

In the following example, you will see how to merge a cell in the worksheet by using the Range object, and also how to use the copy operation by using the Range object in the Excel object model.

Open Visual Studio 2008 and create a new solution, as before. Write the following code inside the Sheet1.cs file:

private void Sheet1_Startup(object sender, System.EventArgs e)
{
// Merging the cell of provided range using cell ranges
Globals.Sheet1.get_Range("A1:A5,B1:B5",
missing).Merge(missing);
// Copy the range of cells and put in another range of cell
Globals.Sheet1.Range["C5", missing].Copy(Range["D5",
missing]);
}

As we can see in the following screenshot, we merged two cells and copied the contents of the cell C5 to cell D5.

VSTO 3.0 for Office 2007 Programming

Unions

A combination of ranges has to be treated as single range, and that range is referred to as the Union. In other words, the display of a group of ranges in a combined format is called a Union. Unions make it easy for the developer to process data inside a worksheet. Generally, a Union is used to calculate a subtotal.

Open Visual Studio 2008 and create a new solution, as usual. Write the following code inside the Sheet1.cs file:

private void Sheet1_Startup(object sender, System.EventArgs e)
{
// Creating Range object instance
Excel.Range AuthorRange1 = this.Application.get_Range("B5",
missing);
// Creating another Range object instance
Excel.Range AuthorRange2 = this.Application.get_Range("C5",
missing);
// Using Union method of current Excel
Excel.Range AuthorRange3 = this.Application.
Union(AuthorRange1, AuthorRange2, missing, missing,
missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing,
missing, missing, missing, missing, missing, missing,
missing, missing);
// Writing the new range using the union operation
AuthorRange3.Value2 = "Programming VSTO Book";
}

 

 

Named ranges

Named ranges are used as replacements for the columns of numbers in Excel spreadsheet. You can use a more indicative name to refer to a column of numbers. Such ranges are known as Named ranges.

Open Visual Studio 2008 and create a new solution, as usual. Write the following code inside the Sheet1.cs file:

// Instance of the NamedRange Class
Microsoft.Office.Tools.Excel.NamedRange AuthorNamedRange = null;
private void Sheet1_Startup(object sender, System.EventArgs e)
{
// Setting range of cells from E1 to G1
Excel.Range AuthorRange = this.Range["E1", "G1"];
// Setting the range name for cells
AuthorNamedRange = this.Controls.AddNamedRange(AuthorRange,
"AuthorCells");
// Updating the values in the cell
AuthorNamedRange.Value2 = "VSTO - My First Book";
}

The following screenshot shows the results of adding and executing the preceding code: Excel

VSTO 3.0 for Office 2007 Programming

Excel host items

Excel host items are classes that offer programming models for developing document-level solutions using VSTO. Document-level customization uses a set of host items that includes Microsoft.Office.Tools.Excel.Worksheet. Worksheet host is one of the host items that acts as a container for controls such as Windows form controls.

VSTO 3.0 for Office 2007 Programming

In Excel, you have three types of host items:

  • Workbook
  • Worksheet
  • ChartSheet

In every Excel solution, there is one workbook host item and a separate worksheet host item for each worksheet in the workbook. All of these host items are folded in the native Excel workbook, Excel worksheet, and the Excel ChartSheet, which together constitute the Microsoft.Office.Interop.Excel namespace.

The workbook host item

A workbook host item is created whenever you create an Excel 2007 workbook project using Visual Studio 2008, that is, document-level customization for Microsoft Office Excel. Visual Studio Tools for Office, by design, creates a workbook host item within the project solution. When programming, you need to reference the workbook using the ThisWorkbook object. The workbook host item is a workbook object model, which is available in the VSTO Excel object model.

There are numerous events exposed in the workbook host item. You will see some of these events in the sample code below. In this example, you're going to see the sample work for the NewWorkbook event in an Excel workbook. First let's see the NewWorkbook event for the workbook host item. Here, let's register the NewWorkbook event in the workbook solution. Within Office 2007 tools such as Excel 2007 and other Office applications, there is an option to handle events by using the Event Manager . The Event Manager provides mechanisms by which forms or documents can provide and respond to events. The Event Manager is called from the InternalStartup() method which in turn controls the events that are registered when a document is initially loaded. Each captured event can be registered within the InternalStartup() method, and then the delegates can be constructed to encapsulate a reference to a method that handles the events' custom code.

Open Visual Studio 2008 and create a new solution, as usual. Write the following code inside the ThisWorkbook.cs file:

private void InternalStartup()
{
// Explicitly cast the application object to the application
events
((Excel.AppEvents_Event)ThisApplication).NewWorkbook += new
Microsoft.Office.Interop.Excel.
AppEvents_NewWorkbookEventHandler(ThisWorkbook_
NewWorkbook);
// Visual Studio generated
this.Startup += new System.EventHandler(ThisWorkbook_Startup);
this.Shutdown += new System.EventHandler(ThisWorkbook_
Shutdown);
}
// NewWorkbook event in the Excel solution
public void ThisWorkbook_NewWorkbook(Microsoft.Office.
Interop.Excel.Workbook AuthorWorkBook)
{
// Reading from Excel using the Range object
Excel.Range AuthorRange = Globals.Sheet1.Range["B1", "D5"] as
Excel.Range;
// Formatting the selected Range with autocolor format
AuthorRange.AutoFormat(Excel.XlRangeAutoFormat.
xlRangeAutoFormatClassic3, true, false, true, false, true,
true);
// Messagebox after range of cells formatted
MessageBox.Show("New workbook name: " + AuthorWorkBook.Name);
}

Now, let's see the WorkbookOpen event of the workbook host item. Here, let's register the WorkbookOpen event in the workbook solution.

private void InternalStartup()
{
// Explicitly cast the application object to the application
events
((Excel.AppEvents_Event)ThisApplication).WorkbookOpen += new
Microsoft.Office.Interop.Excel.
AppEvents_WorkbookOpenEventHandler(ThisWorkbook_WorkbookOpen);
// Visual Studio generated
this.Startup += new System.EventHandler(ThisWorkbook_Startup);
this.Shutdown += new System.EventHandler(ThisWorkbook_
Shutdown);
}
// Open event of Workbook
public void ThisWorkbook_WorkbookOpen(Microsoft.Office.
Interop.Excel.Workbook AuthorWorkBook)
{
// Messagebox shows the name of the file being opened
MessageBox.Show("You are opening workbook name: " +
AuthorWorkBook.Name);
}

The worksheet host item

A worksheet host item is the worksheet in the Excel workbook. You can have more than one worksheet in your workbook. This is an object that exposes events and works as a holder for components. You can add Windows forms controls to the host item, just as you would add them to your Windows forms. Worksheets are the key components of any kind of Excel solution.

The following example will show how to program for the Change event of the cells in the Excel worksheet. Open Visual Studio 2008 and create a new solution, as before. Write the following code inside the ThisWorkbook.cs file. This will register theChange event in the worksheet host item's .cs file:

// Visual studio generated InternalStartup()
private void InternalStartup()
{
// Register your Change event
this.Change += new Microsoft.Office.Interop.Excel.
DocEvents_ChangeEventHandler(Sheet1_Change);
}

The following code should be placed inside the Change event of the worksheet host item:

private void Sheet1_Change(Excel.Range AuthorCellPoint)
{
// Reading the current context of cell which has been changed
string AuthorCellChanged = AuthorCellPoint.
get_Address(missing, missing,Excel.XlReferenceStyle.xlA1,
missing, missing);
// Message displaying the changed cell address
MessageBox.Show("The Cell " + this.Name + " : " +
AuthorCellChanged + " is changed.");
}

Once the code is executed, you'll get a confirmation message in a message box, as shown in the following screenshot:

VSTO 3.0 for Office 2007 Programming

The ChartSheet host item

A ChartSheet host item is a worksheet in an Excel workbook that presents information in the form of charts and graphs. The ChartSheet host item contains only charts, and exposes some events. You cannot add any controls inside the ChartSheet host item even though it is a worksheet in an Excel workbook. The ChartSheet host item works as a holder for components.

In a document-level customization project, you cannot create host items at run time. Another limitation is that when you create a new worksheet host item at run time using the add method, you get a native Microsoft.Office.Interop.Excel worksheet object rather than a Microsoft.Office.Tools.Excel worksheet host item. There are numerous events exposed in the ChartSheet host item. You will see some of these events in the following sample code.

Let's see a demonstration of the MouseUp event of the ChartSheet host item.

Open Visual Studio 2008 and create a new solution, as usual. Right-click on the ExcelWorkbook.xlsx file of your Excel 2007 solution in the Solution Explorer, and select Add New Excel Chart.

VSTO 3.0 for Office 2007 Programming

In the Chart.cs file, you can program your functionality. In this example, let's write a code for the MouseUp event in the ChartSheet host item:

// MouseUp event registration in the Chart Host item.
private void InternalStartup()
{
this.MouseUp += new Microsoft.Office.Interop.Excel.
ChartEvents_MouseUpEventHandler(Chart4_MouseUp);
}
private void Chart4_MouseUp(int Button, int Shift, int x, int y)
{
// Set the constant value for range of cells
Globals.Sheet1.Range["B2", "B4"].Value2 = 15;
Globals.Sheet1.Range["C2", "C4"].Value2 = 18;
// Adding the sheet1 cells as data source
this.SetSourceData(Globals.Sheet1.Range["B2", "C4"],
Excel.XlRowCol.xlColumns);
// Chart display type
this.ChartType = Excel.XlChartType.xlConeColStacked100;
// Message to display the mouse moved
MessageBox.Show("Your clicked at X-axis: " + x.ToString() + "
and Y-axis: " + y.ToString());
}

The following screenshot shows the results of adding and executing the preceding code:

VSTO 3.0 for Office 2007 Programming

The Excel host items are loaded with many features that help Office developers to build optimized Excel solutions. Even though the Excel host item has many features, it has a few drawbacks when using Excel host items for programming.

VSTO 3.0 for Office 2007 Programming Get to grips with Programming Office 2007 using Visual Studio Tools for Office
Published: March 2009
eBook Price: €16.99
Book Price: €26.99
See more
Select your format and quantity:

About the Author :


Vivek Thangaswamy

Vivek Thangaswamy is a Software Solution developer and technical author living and working in the enjoyable surroundings of Chennai city, in India. His range of technical competence stretches across platforms and lines of business, but he specializes in Microsoft enterprise application architectures and Microsoft server-based product integrations. Vivek is currently working for the world's largest software services company in Microsoft Technologies. He holds several Microsoft certifications and Microsoft MVP awards. He has completed his Bachelor of technology degree in Information Technology from one of the world's finest universities and is currently pursuing a Management of Business Administration in Finance degree. Vivek loves spending time with friends and writing poems in his mother tongue.

Books From Packt

C# 2008 and 2005 Threaded Programming: Beginner's Guide
C# 2008 and 2005 Threaded Programming: Beginner's Guide

ASP.NET 3.5 Social Networking
ASP.NET 3.5 Social Networking

Software Testing with Visual Studio Team System 2008
Software Testing with Visual Studio Team System 2008

Implementing Microsoft Dynamics NAV 2009
Implementing Microsoft Dynamics NAV 2009

Learning SQL Server 2008 Reporting Services
Learning SQL Server 2008 Reporting Services

Microsoft Visual C++ Windows Applications by Example
Microsoft Visual C++ Windows Applications by Example

Entity Framework Tutorial
Entity Framework Tutorial

SharePoint Designer Tutorial: Working with SharePoint Websites
SharePoint Designer Tutorial: Working with SharePoint Websites

 

 

 

 

 

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software