473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

vb.net Excel versions

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

Nov 21 '05 #1
11 2714
Hi

BrianDH wrote:
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

Nov 21 '05 #2
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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com:
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


Nov 21 '05 #3
thanks will give it a try!

"Frank Liebelt" wrote:
Hi

BrianDH wrote:
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

Nov 21 '05 #4
Thanks will give it a try!

"scorpion53061" wrote:
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

"BrianDH" <Br*****@discussions.microsoft.com> wrote in message
news:95**********************************@microsof t.com:
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


Nov 21 '05 #5
Kelly,

"scorpion53061" <ad***@nospamherekjmsolutions.com> schrieb:
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 "\" :-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #6
Hi

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


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

Nov 21 '05 #7
On Thu, 28 Oct 2004 10:55:01 -0700, "BrianDH" <Br*****@discussions.microsoft.com> wrote:

¤ 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...b;en-us;244167
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #8
Herfried,

Yeah you got me.......
:)

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eQ**************@TK2MSFTNGP12.phx.gbl:
Kelly,

"scorpion53061" <ad***@nospamherekjmsolutions.com> schrieb:
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 "\" :-).


Nov 21 '05 #9
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.

"Frank Liebelt" <li*********@arcor.de> wrote in message
news:41***********************@newsread4.arcor-online.net:
Hi

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


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


Nov 21 '05 #10
Frank,

Can you open a xml document in Excel 97 using late binding?

"Frank Liebelt" <li*********@arcor.de> wrote in message
news:41***********************@newsread4.arcor-online.net:
Hi

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


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


Nov 21 '05 #11
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...b;en-us;249843
http://support.microsoft.com/default...b;en-us;247579
http://support.microsoft.com/default...b;en-us;244167

Thanks

--
MFM

"Frank Liebelt" wrote:
Hi

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


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

Nov 21 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
17
by: Mansi | last post by:
I need to do some research on how to use excel automation from c#. Does anyone know of any good books related to this subject? Thanks. Mansi
6
by: Jeti [work] | last post by:
I have Office2003 installed, and trying to read excel file from C#. I made ExcelWrapper class, and it worked fine until new version of offide came! Now, when i'm trying to open workbook, i get an...
9
by: Maik | last post by:
Hello, I've developed an assembly, which opens an excel workbook and readout the range names and -values. I'm working with Office XP on my computer. I want to deploy this assembly on computers,...
3
by: Boris Condarco | last post by:
Hi gurus, I'm using excel 2000 to show data that comes from datagrid. The problem is that for any reason the asp.net application maintains the excel open, even though, i do close it. Besides,...
1
by: Brian Conklin | last post by:
Hello Eneryone, I am having a problem. I have written a little app that will take a text "pipe" delimited file and place all of the values in to an Excel spreadsheet. It works great on any of my...
3
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
7
by: Alain \Mbuna\ | last post by:
Hi everybody. In my program I have some data that is calculated after some input from the user. I have written some code that opens an Excel workbook, with 5 worksheets and the calculated data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.