all groups > dotnet interop > december 2006 >
You're in the

dotnet interop

group:

.NET interop with multiple versions of Office (2002 and 2003)


.NET interop with multiple versions of Office (2002 and 2003) Sebastian Daser
12/4/2006 1:59:29 PM
dotnet interop:
Hi,

I am adding a function to my VB.NET application that allows reading data
from an Excel file. I have added a reference to "Microsoft Excel 11.0 Object
Library", since I have Office 2003 on my PC.

This is working fine so far, but the application will also be installed on
PCs with Office 2002. Will this work or do I have to reference "Microsoft
Excel 10.0 Object Library" in that case.

Since I cannot reference "Microsoft Excel 11.0 Object Library" and
"Microsoft Excel 10.0 Object Library" at the same time, what is the best way
making my application work with both versions of office?

By the way: I would like to avoid using the CreateObject method since I
generally try to avoid late binding.

Any ideas would be appreciated.

Thanks,
Sebastian.

Re: .NET interop with multiple versions of Office (2002 and 2003) Cindy M.
12/5/2006 6:59:58 PM
Hi Sebastian,

[quoted text, click to view]
The best way to approach something like this is to program and test against the
oldest application version. Often, the newer version will pick up a reference
to the newer library. And backwards compatibility should be more or less OK.
Going the other way is always dangerous because you don't know if what you're
doing is even supported in the older version.

Actually, Microsoft recommends creating a separate solution for each Office
version. Or using late binding.

There is no way to "trick" your assembly into referencing an object library
that's not present on the development machine. So the "best answer" to your
question is to obtain Office XP and install it on a separate machine or a
virtual machine for testing (and compiliation, if at all possible).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
Re: .NET interop with multiple versions of Office (2002 and 2003) Sebastian Daser
12/12/2006 1:22:37 PM
Hi Cindy,

Thanks for your information.

Best regards,

Sebastian

[quoted text, click to view]

AddThis Social Bookmark Button