LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Detect what version (if any) of Excel is installed


Check whether Excel exists at all could be done by
searching for EXCEL.EXE.


Rather than a slow file search for Excel.exe, it would be much
faster to use FindExecutable to find the program that is
associated with the 'xls' file extension.


Declare Function GetTempFileName Lib "kernel32" _
Alias "GetTempFileNameA" ( _
ByVal lpszPath As String, _
ByVal lpPrefixString As String, _
ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long
Declare Function FindExecutable Lib "shell32.dll" _
Alias "FindExecutableA" ( _
ByVal lpFile As String, _
ByVal lpDirectory As String, _
ByVal lpResult As String) As Long


Sub AAA()

Dim FName As String
Dim FNum As String
Dim ExeName As String
Dim Res As Long
FName = String$(255, " ")
ExeName = String$(255, " ")
Res = GetTempFileName(CurDir, "", 0&, FName)
FName = Application.Trim(FName)
Mid$(FName, Len(FName) - 2, 3) = "xls"
FNum = FreeFile
Open FName For Output As #FNum
Close #FNum
Res = FindExecutable(FName, vbNullString, ExeName)
Kill FName
If Res 32 Then
' association found
ExeName = Left$(ExeName, InStr(ExeName, Chr(0)) - 1)
Else
' no association found
ExeName = ""
End If
MsgBox "Excel is: " & ExeName

End Sub

This won't tell you what version of Excel is found (that would
call for a variety of registry calls) but would indicate that
some version of Excel is installed.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Harlan Grove" wrote in message
...
"Bob Phillips" wrote...
Use

application.version

..

Kinda Chicken & Egg-ish. If there's no version of Excel at all,

there's no way
to execute this statement. Check whether Excel exists at all

could be done by
searching for EXCEL.EXE.

--
To top-post is human, to bottom-post and snip is sublime.



 
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 save an Excel 97-2003 version or 2007 version for Mac 200 Bronigal Excel Discussion (Misc queries) 1 December 7th 09 08:04 AM
Fill color not functioning in newly installed version of excel. Vernon Antoine Brou Jr. Excel Worksheet Functions 2 October 24th 06 09:55 PM
HELP: how to detect if printers are installed? woes :S KevinGPO Excel Worksheet Functions 1 March 14th 06 09:58 AM
Recover earlier version of excel sheet after new version saved? stephanie38 Excel Discussion (Misc queries) 3 June 17th 05 03:52 AM
Detect Excel Version Stacy Haskins Excel Programming 2 August 19th 03 09:55 PM


All times are GMT +1. The time now is 08:17 AM.

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

About Us

"It's about Microsoft Excel"