vb.net Excel versions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
Is there a way, in VB.Net, to write a windows based program that will use
more than one version of Office (Excel)?

Example: if office 2000 then else if office 2003 then.

Is this possible? Examples?

Thanks
 
Hi
Hi
Is there a way, in VB.Net, to write a windows based program that
will use more than one version of Office (Excel)?

Example: if office 2000 then else if office 2003 then.

Is this possible? Examples?

Late-Binding is your friend
Dim xlAppl As Object = CreateObject("Excel.Application")

Frank
 
Use the registry to check the version....

Pseudo code untested.


Public Function getInstance1() As Excel.ApplicationClass
Dim regVersion As RegistryKey
Dim keyValue As String
Dim versionnumber As Integer = 9
Do
keyValue = "Software\\Microsoft\\Office\\" & versionnumber &
".0\\Excel"
regVersion = Registry.LocalMachine.OpenSubKey(keyValue,
False)
If regVersion Is Nothing Then
'Do this and exit
End If
If versionnumber = 10 Then

'Do this

End If

Exit Do
Loop
End Function
 
Thanks will give it a try!

scorpion53061 said:
Use the registry to check the version....

Pseudo code untested.


Public Function getInstance1() As Excel.ApplicationClass
Dim regVersion As RegistryKey
Dim keyValue As String
Dim versionnumber As Integer = 9
Do
keyValue = "Software\\Microsoft\\Office\\" & versionnumber &
".0\\Excel"
regVersion = Registry.LocalMachine.OpenSubKey(keyValue,
False)
If regVersion Is Nothing Then
'Do this and exit
End If
If versionnumber = 10 Then

'Do this

End If

Exit Do
Loop
End Function
 
Kelly,

scorpion53061 said:
Use the registry to check the version....

Pseudo code untested.
:-)

Public Function getInstance1() As Excel.ApplicationClass
Dim regVersion As RegistryKey
Dim keyValue As String
Dim versionnumber As Integer = 9
Do
keyValue = "Software\\Microsoft\\Office\\" & versionnumber &
".0\\Excel"

The "\\" should be "\" :-).
 
Hi

With this code you could read the excel version but it doesn't make the
application able to work with different excel versions.
Example:
I have Excel 2003, the application has a reference to the Excel(11) COM
Object.
The user has Excel 2000 (10). The only i can do is inform the user that
his Excel version won't work with this application.
But with Late-Binding the application works with Excel 97, 2000, XP,
2003 without any reference.

Late-Binding makes a application independent from any version.

Frank
 
¤ Hi
¤ Is there a way, in VB.Net, to write a windows based program that will use
¤ more than one version of Office (Excel)?
¤
¤ Example: if office 2000 then else if office 2003 then.
¤
¤ Is this possible? Examples?

See the following:

INFO: Writing Automation Clients for Multiple Office Versions
http://support.microsoft.com/default.aspx?scid=kb;en-us;244167


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
Frank,

The idea is to take the version number garnered, then if code your app
around the idea if they have 10 and you know your code needs to adapt to
that version so all versions are available. This is the method one could
use to find the office version on the end users machine and try to
accommodate all versions in your code.

As a general rule, the office versions are backward compatible. What
works for office 2000 will work for office 2003.

Unfortunately this general rule gets broken on occasion which makes it
necessary for you to have case statements saying what to do for a
particular version of office. Even using late binding is no guarantee in
all cases you are going to be safe in all office versions for a
particular event.
 
Hello Guys:

Does anyone know How to create an Excel event handler while using late
binding?

I had to use late binding because my application must run across multiple
MS-Office versions, but I need to catch WorkbookBeforeClose Event of the
application object.

I tried both: delegates and WithEvents keyword like I found in Microsoft
documents, but it doesn't work because those methods use early binding.

http://support.microsoft.com/default.aspx?scid=kb;en-us;249843
http://support.microsoft.com/default.aspx?scid=kb;en-us;247579
http://support.microsoft.com/default.aspx?scid=kb;en-us;244167

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top