Search code examples
c#excelcom

Difference between Interop.Excel and Tools.Excel?


I'm currently working on an AddIn for Microsoft Excel, and I'm a little confused about something :

What are the differences between Interop.Excel and Tools.Excel ? For example, between Interop.Excel.Workbook and Tools.Excel.Workbook ? Or Interop.Excel.Worksheet and Tools.Excel.Worksheet ?

What are they used for, where do I use which one ? Is it possible to cast from one to another ?

Thanks!!


Solution

  • Microsoft.Office.Tools.Excel is the set of objects exposed by visual studio tools for office, for Excel projects. If you're doing straight Interop, using the Shared Add-in template, then you shouldn't reference this library in your project. It's only relevant if you're creating a project based on a VSTO template.

    If you created the Add-in from a template labelled for Excel, under the Office folder in the New Project dialog box, then you need to leave this reference. The library comes into play, for example, when you use the Globals.ThisApplication keyword. This page will give you some explanation and links to a topic about the Tools.Excel library: http://msdn2.microsoft.com/en-us/library/wss56bz7.aspx

    Source : http://social.msdn.microsoft.com/forums/en-US/vsto/thread/86a62151-fbf0-4584-a68c-83060fb95c3d