473,320 Members | 1,841 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,320 software developers and data experts.

How to check Excel version number with .net?

Hi everybody.

Does anyone know what code I should use to check for the version number of
Excel, installed on a computer?

Thanks.

Alain.
Jan 4 '06 #1
7 3349
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
Does anyone know what code I should use to check for the version number of
Excel, installed on a computer?


\\\
Dim o As Object = CreateObject("Excel.Application")
If Not o Is Nothing Then
On Error Resume Next
MsgBox( _
"Installed version of Excel: " & _
DirectCast(o.Version, String) _
)
o.Quit()
On Error GoTo -1
Marshal.ReleaseComObject(o)
Else
MsgBox("Maybe Excel is not installed!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 4 '06 #2
That was fast!!!

Thanks a lot.

Alain.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:Oh*************@TK2MSFTNGP09.phx.gbl...
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
Does anyone know what code I should use to check for the version number
of Excel, installed on a computer?


\\\
Dim o As Object = CreateObject("Excel.Application")
If Not o Is Nothing Then
On Error Resume Next
MsgBox( _
"Installed version of Excel: " & _
DirectCast(o.Version, String) _
)
o.Quit()
On Error GoTo -1
Marshal.ReleaseComObject(o)
Else
MsgBox("Maybe Excel is not installed!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 4 '06 #3
What is the Marshal thing???

This word is underlined in the code, saying it is not declared???

Alain.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:Oh*************@TK2MSFTNGP09.phx.gbl...
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
Does anyone know what code I should use to check for the version number
of Excel, installed on a computer?


\\\
Dim o As Object = CreateObject("Excel.Application")
If Not o Is Nothing Then
On Error Resume Next
MsgBox( _
"Installed version of Excel: " & _
DirectCast(o.Version, String) _
)
o.Quit()
On Error GoTo -1
Marshal.ReleaseComObject(o)
Else
MsgBox("Maybe Excel is not installed!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 4 '06 #4
Herfried K. Wagner [MVP] wrote:
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
Does anyone know what code I should use to check for the version
number of Excel, installed on a computer?

\\\
Dim o As Object = CreateObject("Excel.Application")
If Not o Is Nothing Then
On Error Resume Next
MsgBox( _
"Installed version of Excel: " & _
DirectCast(o.Version, String) _
)
o.Quit()
On Error GoTo -1
Marshal.ReleaseComObject(o)
Else
MsgBox("Maybe Excel is not installed!")
End If
///


If you looked in help you would see it.

Try:
System.Runtime.InteropServices.Marshal.ReleaseComO bject(o)
Jan 4 '06 #5
Import System.Runtime.InteropServices

--
Colin Neller
http://www.colinneller.com/blog
"Alain "Mbuna"" <mb***@telenet.be> wrote in message
news:5X********************@phobos.telenet-ops.be...
What is the Marshal thing???

This word is underlined in the code, saying it is not declared???

Alain.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:Oh*************@TK2MSFTNGP09.phx.gbl...
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
Does anyone know what code I should use to check for the version number
of Excel, installed on a computer?


\\\
Dim o As Object = CreateObject("Excel.Application")
If Not o Is Nothing Then
On Error Resume Next
MsgBox( _
"Installed version of Excel: " & _
DirectCast(o.Version, String) _
)
o.Quit()
On Error GoTo -1
Marshal.ReleaseComObject(o)
Else
MsgBox("Maybe Excel is not installed!")
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Jan 4 '06 #6
"Alain "Mbuna"" <mb***@telenet.be> schrieb:
What is the Marshal thing???

This word is underlined in the code, saying it is not declared???


Import the namespace 'System.Runtime.InteropServices'. It's used to release
the Excel COM object to free Excel.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 4 '06 #7
On Wed, 04 Jan 2006 20:28:30 GMT, "Alain \"Mbuna\"" <mb***@telenet.be> wrote:

¤ Hi everybody.
¤
¤ Does anyone know what code I should use to check for the version number of
¤ Excel, installed on a computer?
¤

You can also use the FindExecutable API function call (which doesn't launch the Excel application):

Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As
String, _
ByVal lpDirectory As
String, _
ByVal lpResult As
System.Text.StringBuilder) As Int32

Function IsExcelInstalled(ByRef FileVersionMajor As String) As Boolean

Dim DummyFile As String
Dim FileDir As String

Dim FilePath As New System.Text.StringBuilder(255)
DummyFile = "e:\My Documents\book1.xls"

If FindExecutable(DummyFile, FileDir, FilePath) > 32 Then
IsExcelInstalled = True
FileVersionMajor =
System.Diagnostics.FileVersionInfo.GetVersionInfo( FilePath.ToString).FileMajorPart
End If

End Function
Paul
~~~~
Microsoft MVP (Visual Basic)
Jan 5 '06 #8

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

Similar topics

5
by: Axial | last post by:
Question: How to select columns from Excel-generated XML when some cells are empty. I've found examples where rows are to be selected, but I can't seem to extrapolate from that to selecting...
8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
1
by: Vanajakshi Pidatala | last post by:
Hello, I am trying to show data in dataset in to an excel sheet(ASP.NET/VB.NET). I AM DOING THIS ON SERVER(IIS SERVER) WHICH HAS EXCEL VERSION 9. I COULD ADD REFERENCE TO EXCEL VERSION 9 AND...
11
by: BrianDH | last post by:
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? ...
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...
18
by: gonzlobo | last post by:
No, I don't want to destroy them (funny how the word 'decimate' has changed definition over the years) :). We have a data acquisition program that saves its output to Excel's ..xls format....
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.