scotsman60

Hello,

I am using VSTO to develop an application on top of Excel. I currently have both Excel 2003 and 2007 installed on the machines where I develop the app and on the machines where it is deployed.

The problem I have is how to choose which version of Excel to use. Currently, my application always uses Excel 2003 and I can't see any way to choose 2007.

Here's how I invoke the Excel app....

"app = new Microsoft.Office.Interop.Excel.Application();"

Any help gratefully received.....

Doug



Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

Andrew Cherry [MSFT]

Hi Doug -

This should not be necessary for an VSTO Excel application, as they would be hosted by Excel, rather than hosting Excel themselves.

Regardless, the issue you're seeing is due to how Office registers their application and COM portions. Office deliberately shares the same registration information across versions -- this way, a downloaded XLS file SHOULD always open with the newest version.

The determination of which version is launched by automation (including your "new" line) is determined by which version was the last one registered on your system. Repairing the Office 2007 (or 2003, depending on which you want to use) installation in Add/Remove Programs will make the repaired version be the new default. Excel specifically, however, does have some logic that fixes up some of the registry settings, so running the appropriate version of Excel from the Start menu may be sufficient to set it as the default.

Unfortunately, there's really no way to specify it via code, short of automating the repair process.

HTH,

Andrew






Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

scotsman60

Andrew,

Thanx for the reply.

My application is not a hosted solution it's an automation executable - Excel is hosted within my application. This is why I have the probelm.

Anyway it seems clear that I can't mix and match different versions of Excel using this approach so I'll just deal with that, even though it does seem kind of strange and at least inconvenient that MS doesn't offer the ability to select which version of Excel you want to use.

Thanx again,

Doug





Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

prashanth_prolific_coder

Adding to this...

is there a way to atleast determine of the version they are using is 2003 or 2007.

There is part of my code that runs with 2007 and not with 2003 and throws an exception.

the

Code Block
application.version

returns me a 2003 user,

Code Block
11.0

is this the same always for all users of 2003 office across all service packs






Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

Andrew Cherry [MSFT]

Application.Version should never vary; 11 = 2003, 12 = 2007. It is possible that Excel will start returning minor version numbers (Service Packs, QFEs) in the .Version method to provide better clarity as to the running configuration.

I would use Application.Version.StartsWith to check, rather than just an explicit comparison.

Andrew






Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

prashanth_prolific_coder

Well I converted that to application.version to a float and checking that its less than 12 to make sure its backwardly compatible.

do u foresee any trouble






Re: Visual Studio Tools for Office How to choose which version of Excel (2003 or 2007) to invoke

Andrew Cherry [MSFT]

That should work fine; there shouldn't be any case when Excel 2003 starts reporting 12.0 or higher.

Andrew