Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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
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


  #2   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
external usenet poster
 
Posts: 1
Default How do I access different versions of Excel from one .NET executable?

Usually it is most easy to install the earliest version of excel you want to
use on the development machine. Then reference that version instead in your
project.

You might be able to install them side by side so no need to uninstall 2007.



  #3   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
external usenet poster
 
Posts: 1,049
Default How do I access different versions of Excel from one .NET executable?

you can have multiple versions of Excel installed....and you'll then have
access to each Excel library.
your code should be able to instantiate Excel, and use the relevant library.

"John Brock" wrote in message
...
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


  #4   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
external usenet poster
 
Posts: 43
Default How do I access different versions of Excel from one .NET executable?

Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.

Anyway, to be certain I understand, you are saying that once I
install both versions of Office (with both sets of PIAs), that my
project should reference *both* the 11.0 and 12.0 versions of the
Microsoft Excel Office Library, and the appropriate reference will
be used depending on what is on a particular machine?

But what will happen on *my* machine? The VB code that accesses
Excel doesn't specify a version, so if both versions are available,
which will be instantiated?

Also, what happens to my file associations if I have two versions
of Office? I'm pretty nervous about taking this route. Maybe
there is some way I can install and reference the Office 2003 PIAs
without actually installing Office 2003?

In article ,
Patrick Molloy wrote:
you can have multiple versions of Excel installed....and you'll then have
access to each Excel library.
your code should be able to instantiate Excel, and use the relevant library.

"John Brock" wrote in message
...
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




--
John Brock


  #5   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
external usenet poster
 
Posts: 43
Default How do I access different versions of Excel from one .NET executable?

OK, you are saying that if my program references the Office 2003
PIA (Microsoft Excel 11.0 Object Library) this will work with later
versions of Excel, but not the reverse. This is actually the
opposite of what I would have expected. Any idea what is going on
here? And is this likely to hold when Office 2010 comes out.

In article ,
Andreas Johansson wrote:
Usually it is most easy to install the earliest version of excel you want to
use on the development machine. Then reference that version instead in your
project.

You might be able to install them side by side so no need to uninstall 2007.

--
John Brock




  #6   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
external usenet poster
 
Posts: 1,049
Default How do I access different versions of Excel from one .NET executable?

i didn't say OFFICE, I said Excel
I run Excel 2003 and Excel 2007
When installing Office, there's an option that allows you to keep older
versions.


"John Brock" wrote in message
...
Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.

Anyway, to be certain I understand, you are saying that once I
install both versions of Office (with both sets of PIAs), that my
project should reference *both* the 11.0 and 12.0 versions of the
Microsoft Excel Office Library, and the appropriate reference will
be used depending on what is on a particular machine?

But what will happen on *my* machine? The VB code that accesses
Excel doesn't specify a version, so if both versions are available,
which will be instantiated?

Also, what happens to my file associations if I have two versions
of Office? I'm pretty nervous about taking this route. Maybe
there is some way I can install and reference the Office 2003 PIAs
without actually installing Office 2003?

In article ,
Patrick Molloy wrote:
you can have multiple versions of Excel installed....and you'll then have
access to each Excel library.
your code should be able to instantiate Excel, and use the relevant
library.

"John Brock" wrote in message
...
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




--
John Brock


  #7   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
external usenet poster
 
Posts: 1
Default How do I access different versions of Excel from one .NET executable?

But yes, you can have two different versions of *Office*, but not Outlook.

"Patrick Molloy" wrote in message
...
:i didn't say OFFICE, I said Excel
: I run Excel 2003 and Excel 2007
: When installing Office, there's an option that allows you to keep older
: versions.
:
:
: "John Brock" wrote in message
: ...
: Hmmm..., are you *sure* you can have two (or more) versions of
: Office on the same machine? I could swear that I read somewhere
: this isn't possible.
:
: Anyway, to be certain I understand, you are saying that once I
: install both versions of Office (with both sets of PIAs), that my
: project should reference *both* the 11.0 and 12.0 versions of the
: Microsoft Excel Office Library, and the appropriate reference will
: be used depending on what is on a particular machine?
:
: But what will happen on *my* machine? The VB code that accesses
: Excel doesn't specify a version, so if both versions are available,
: which will be instantiated?
:
: Also, what happens to my file associations if I have two versions
: of Office? I'm pretty nervous about taking this route. Maybe
: there is some way I can install and reference the Office 2003 PIAs
: without actually installing Office 2003?
:
: In article ,
: Patrick Molloy wrote:
: you can have multiple versions of Excel installed....and you'll then
have
: access to each Excel library.
: your code should be able to instantiate Excel, and use the relevant
: library.
:
: "John Brock" wrote in message
: ...
: 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
:
:
:
:
: --
: John Brock
:

:


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

Hello John,

Yes that is the case. You cannot reference the later PIA because these contain
new functionality not yet available when the previous version came out. But
the old excel functions are still built into the new executables, so the
older PIA will work regardless of later upgrades. Until MS decides to deprecate
such functions in later versions

Knowing that we'll have a 64 bit version of the next Office, I guess that
there will be a break in backwards compatibility as I doubt that a 32 bit
PIA for Excel 2003 would be able to load Excel 2010 64 bit. It should still
work with the 32 bit version though. (not verified nor tested)

Jesse

OK, you are saying that if my program references the Office 2003 PIA
(Microsoft Excel 11.0 Object Library) this will work with later
versions of Excel, but not the reverse. This is actually the opposite
of what I would have expected. Any idea what is going on here? And
is this likely to hold when Office 2010 comes out.

In article ,
Andreas Johansson wrote:

Usually it is most easy to install the earliest version of excel you
want to use on the development machine. Then reference that version
instead in your project.

You might be able to install them side by side so no need to
uninstall 2007.

--
Jesse Houwing
jesse.houwing at sogeti.nl


  #9   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
external usenet poster
 
Posts: 2
Default How do I access different versions of Excel from one .NET executable?

The general answer to this is to forget version-specific PIAs and use the
late-binding scripting interfaces. It's pretty ugly, as you can see from
this:
http://support.microsoft.com/kb/302902

but it's been used for years by scripting clients.
--
Phil Wilson

"John Brock" wrote in message
...
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



  #10   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
external usenet poster
 
Posts: 27
Default How do I access different versions of Excel from one .NET executable?

In article , John Brock wrote:
Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.


It is possible (but not supported).

However, the replies you're getting seem mostly directed at "Can I have both
installed on one PC" and your question is more about "Can I develop in Visual
Studio for both on one PC?"

My understanding is that you can't (or that you'd need to do at least half your
dev in a virtual machine). I'd bring up the same questions in a group devoted
to .NET/Visual Studio/VSTO.





  #11   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
external usenet poster
 
Posts: 43
Default How do I access different versions of Excel from one .NET executable?

In article ,
Steve Rindsberg wrote:
In article , John Brock wrote:
Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.


It is possible (but not supported).

However, the replies you're getting seem mostly directed at "Can I have both
installed on one PC" and your question is more about "Can I develop in Visual
Studio for both on one PC?"

My understanding is that you can't (or that you'd need to do at least half your
dev in a virtual machine). I'd bring up the same questions in a group devoted
to .NET/Visual Studio/VSTO.


Can you suggest such a group? I didn't see anything like that on
Usenet.

Also, do you have any idea whether it is possible to install the
Office 2003 PIAs on my machine, in addition to the PIAs that came
with Office 2007, without actually installing Office 2003? It
appears from what folks are saying that the earlier PIAs will work
with later versions of Office, so if I could use those that would
be the simplest thing.

Of course, in the same vein, I could always uninstall Office 2007
and install Office 2003. That would be sad, but it would still
beat having to buy another machine, or keep a duplicate code base
on a virtual machine. :-(
--
John Brock


  #12   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
external usenet poster
 
Posts: 43
Default How do I access different versions of Excel from one .NET executable?

Very interesting!!! I knew about reflection and late binding, but
it didn't occur to me that they could be used for this. (I assume
this method will work just as well for VB.NET as for C#)?

Yes, coding would be ugly. I would especially miss Intellisense.
But it looks like doing it this way would remove all version worries.
(I'm not doing anything especially sophisticated with Excel, so
whatever I need is going to be there in all versions). In addition,
I wouldn't even have to worry about whether any PIAs were installed
on the end user's machine (which is not guaranteed). Have I
understood all this correctly?

In practice I think I would end up coding everything first using
the Excel PIA, just to see what all the calls ended up looking
like, and then translating everything to late binding. Yes, ugly,
but maybe the best way. Thanks!

In article ,
Wilson, Phil wrote:
The general answer to this is to forget version-specific PIAs and use the
late-binding scripting interfaces. It's pretty ugly, as you can see from
this:
http://support.microsoft.com/kb/302902

but it's been used for years by scripting clients.
--
Phil Wilson


"John Brock" wrote in message
...
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

--
John Brock


  #13   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
external usenet poster
 
Posts: 1
Default How do I access different versions of Excel from one .NET executable?

On Fri, 15 May 2009 04:47:15 +0000 (UTC), (John
Brock) wrote:

In article ,
Steve Rindsberg wrote:
In article , John Brock wrote:
Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.


It is possible (but not supported).

However, the replies you're getting seem mostly directed at "Can I have both
installed on one PC" and your question is more about "Can I develop in Visual
Studio for both on one PC?"

My understanding is that you can't (or that you'd need to do at least half your
dev in a virtual machine). I'd bring up the same questions in a group devoted
to .NET/Visual Studio/VSTO.


Can you suggest such a group? I didn't see anything like that on
Usenet.

Also, do you have any idea whether it is possible to install the
Office 2003 PIAs on my machine, in addition to the PIAs that came
with Office 2007, without actually installing Office 2003? It
appears from what folks are saying that the earlier PIAs will work
with later versions of Office, so if I could use those that would
be the simplest thing.

Of course, in the same vein, I could always uninstall Office 2007
and install Office 2003. That would be sad, but it would still
beat having to buy another machine, or keep a duplicate code base
on a virtual machine. :-(


If you go to <http://www.microsoft.com/downloads/en/default.aspx and
search for 'office pia' there appear to be downloads for Office XP,
Office 2003 and Office 2007.
  #14   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
external usenet poster
 
Posts: 27
Default How do I access different versions of Excel from one .NET executable?

In article , John Brock wrote:
In article ,
Steve Rindsberg wrote:
In article , John Brock wrote:
Hmmm..., are you *sure* you can have two (or more) versions of
Office on the same machine? I could swear that I read somewhere
this isn't possible.


It is possible (but not supported).

However, the replies you're getting seem mostly directed at "Can I have both
installed on one PC" and your question is more about "Can I develop in Visual
Studio for both on one PC?"

My understanding is that you can't (or that you'd need to do at least half your
dev in a virtual machine). I'd bring up the same questions in a group devoted
to .NET/Visual Studio/VSTO.


I'm not a .Net developer myself; I just look into it from time to time to see
whether it'll suit my needs. So far, it's more about PITA than PIA. YMMV, of
course.

Now that you're armed with that grain of salt ...

Can you suggest such a group? I didn't see anything like that on
Usenet.


microsoft.public.vsnet.vstools.office
microsoft.public.vsnet.*
microsoft.public.vstudio.*

(*=various groups following the dot)

Also look into the various microsoft.public.Office.Developer.* groups.

Also, do you have any idea whether it is possible to install the
Office 2003 PIAs on my machine, in addition to the PIAs that came
with Office 2007, without actually installing Office 2003? It
appears from what folks are saying that the earlier PIAs will work
with later versions of Office, so if I could use those that would
be the simplest thing.


I don't know enough to answer that one.

Of course, in the same vein, I could always uninstall Office 2007
and install Office 2003. That would be sad, but it would still
beat having to buy another machine, or keep a duplicate code base
on a virtual machine. :-(


I doubt that *very* much. Worst case, you could copy/paste your code between
machines in seconds, or put it on an external or network drive and use it from
either the physical or virtual machine. With at least some virtualization
software, you can share a directory from the physical machine to a mapped drive on
the VM. No code movement required at all.

That vs uninstalling one Office version, installing the other? No contest.

And that's not taking activation into account.


  #15   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
external usenet poster
 
Posts: 27
Default How do I access different versions of Excel from one .NET executable?

In article , John Brock wrote:
Very interesting!!! I knew about reflection and late binding, but
it didn't occur to me that they could be used for this. (I assume
this method will work just as well for VB.NET as for C#)?


It does for VB and VBA. Unless they've crippled VB.NET for some obscure
reason, it should work.

Yes, coding would be ugly. I would especially miss Intellisense.


Again, I don't know how you'd do it in .Netspeak but in VB/VBA, you can:

Dim oSlide as PowerPoint.Slide
'Dim oSlide as Object

Write your code using Intellisense, then when it's all working, move the
apostrophes around in your declaration so you have:

'Dim oSlide as PowerPoint.Slide
Dim oSlide as Object

Instant late-binding w/o the Ugly.





  #16   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
external usenet poster
 
Posts: 2
Default How do I access different versions of Excel from one .NET executable?

If you're doing simple things you should be fine. That's what got me
started - all I wanted to do was send Outlook mail, and the late-binding to
do all that has been around for years without PIAs.
--
Phil Wilson

"John Brock" wrote in message
...
Very interesting!!! I knew about reflection and late binding, but
it didn't occur to me that they could be used for this. (I assume
this method will work just as well for VB.NET as for C#)?

Yes, coding would be ugly. I would especially miss Intellisense.
But it looks like doing it this way would remove all version worries.
(I'm not doing anything especially sophisticated with Excel, so
whatever I need is going to be there in all versions). In addition,
I wouldn't even have to worry about whether any PIAs were installed
on the end user's machine (which is not guaranteed). Have I
understood all this correctly?

In practice I think I would end up coding everything first using
the Excel PIA, just to see what all the calls ended up looking
like, and then translating everything to late binding. Yes, ugly,
but maybe the best way. Thanks!

In article ,
Wilson, Phil wrote:
The general answer to this is to forget version-specific PIAs and use the
late-binding scripting interfaces. It's pretty ugly, as you can see from
this:
http://support.microsoft.com/kb/302902

but it's been used for years by scripting clients.
--
Phil Wilson


"John Brock" wrote in message
...
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

--
John Brock



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I Run An Executable from Excel? [email protected] Excel Programming 1 October 28th 08 05:09 PM
Excel into executable MrBT Excel Worksheet Functions 2 May 1st 08 03:05 AM
Reference different versions of Access Noemi Excel Programming 2 November 13th 07 06:31 AM
Can't load Excel Executable rickSA007 Setting up and Configuration of Excel 0 June 28th 06 11:50 AM
Excel file as an executable? James Excel Programming 4 September 7th 05 08:51 PM


All times are GMT +1. The time now is 03:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"