C# – How to obtain specific Excel object library without the corresponding Office version installed

cms-office

I am developing a Excel automation app that read and write to Excel spreadsheet. I have Office 2007 installed on my machine. I therefore can reference the Excel 12.0 Object Library and the Excel 5.0 Object Library. I don't want to use Excel 5.0 because it's really quite old and poorly documented. Therefore I'm referencing Excel 12.0.

However the target machine have Office 2003 installed and therefore only have Excel 11.0. So when I compile my program it crashes on the target machine since the referenced library are different.

I was wondering is there a way I could obtain the Excel 11.0 without installing Office 03? I tried to find answers from msdn and microsoft support page but couldn't find anything? This is quite strange since it could also happen in the future where developers has newer editions of Office than clients?

Best Answer

Look at my open source project MS Office Wrapper for .NET. The instance of Office application object is created dynamically via "CreateObject" method and then is used late-binding ability, so you don't need any "strong reference" to any version of MS Office libraries.

You can use C#, VB.NET, J#, etc...

The source code is available too.