Supporting Multiple Versions Of Excel

  • Thread starter Thread starter Nick Carter
  • Start date Start date
N

Nick Carter

I am automating Excel 2000 using the COM interop. I have noticed that the
application doesn't run with Excel 97. I want to write just one piece of
code which will work with both Excel 2000 and Excel 97. How can I do this
when they have different type libraries ? I could dynamically load the
relevant type library (i.e. Excel 2000 or Excel 97) on the target machine
and create my necessary objects (i.e. ExcelApplication and ExcelWorkbook)
using Activator.CreateInstance but this will return a System.Object. I think
that I would be unable to cast it into something useful (like an
ExcelApplication or ExcelWorkbook) because these types are dynamically
loaded from the type library.

Inpiration desired.

Nick Carter
 
When creating an Office app that is to run on multiple versions, you have
two choices:

1. Build the app using the earliest library you wish to support.
2. Use late binding.
 
Back
Top