View Single Post
  #1   Report Post  
Posted to microsoft.public.vstudio.general,microsoft.public.dotnet.framework.interop,microsoft.public.dotnet.general,microsoft.public.office.misc,microsoft.public.excel.programming
John Brock John Brock is offline
external usenet poster
 
Posts: 43
Default How do I access different versions of Excel from one .NET executable?

I want to use Visual Studio (2008, writing in VB.NET) to create an
EXE file that will, among other things, read from and write to
Excel workbooks. In particular, I want the program to work whether
the machine has Office 2003 or Office 2007 installed. (Other
versions of Excel would also be nice -- in particular 2010, when
it comes out -- but those two are critical).

I have no trouble accessing Excel 2007 on my own PC; however when
I copy the EXE file to a PC with Office 2003 installed the program
fails when it hits the Excel access code. (Note that VB.NET programs
compiled on the other PC are able to read and write Excel 2003
files on that machine, so that's not the problem).

I do know something about PIAs, although perhaps not enough. My
project makes a COM reference to the Microsoft Excel 12.0 Office
Library, which allows it to access Excel 2007. I believe that to
access Excel 2003 I would need to reference the 11.0 library, which
doesn't exist on my machine, so I can't reference it. Even if it
did, I don't know if it's possible or would make sense to reference
both libraries in the same project.

So what do I do? My requirement seems very straightforward --
something that a lot of people would want to do. But I've looked
around a bit without finding a way to do it. Indeed, I've found
disturbing suggestions that I will need to compile a separate
version of my program for each version of Office I want to be
compatible with, which would be very unpleasant. (Just for starters,
since you can't have two versions of Office on the same machine,
I would need to get a second PC just for this!).

I am really hoping that Microsoft has not made my life that difficult.
So can anyone give me some advice, or point me to documentation
that might help me out?
--
John Brock