![]() |
How to check programmatically whether Excel is installed on computer?
I mean Excel installed, not running.
|
How to check programmatically whether Excel is installed on computer?
The most trustworthy would be to start it with CreateObject. (or use
GetObject which would get an existing running instance if one was up). -- Regards, Tom Ogilvy Jack <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
How to check programmatically whether Excel is installed on computer?
Hi Jack,
There are lots of ways, this one attempts to start Excel in the background and checks for an error to be raised. The drawback is this method of checking will take longer than other options, the benefit is that it is simple and will work with any version of Excel. Public Function IsExcelInstalled() As Boolean Dim obj As Object IsExcelInstalled = True On Error GoTo ErrHandler Set obj = CreateObject("Excel.Application") Set obj = Nothing Exit Function ErrHandler: IsExcelInstalled = False End Function -- Rob Windsor [MVP-VB] G6 Consulting Toronto, Canada "Jack" <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
How to check programmatically whether Excel is installed on computer?
Tom, not running theExcel instance, but the existance of the installed
program I need to check. "Tom Ogilvy" wrote in message ... The most trustworthy would be to start it with CreateObject. (or use GetObject which would get an existing running instance if one was up). -- Regards, Tom Ogilvy Jack <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
How to check programmatically whether Excel is installed on computer?
I understand what you want. Answer is the same.
-- Regards, Tom Ogilvy Jack <replyto@newsgroup wrote in message ... Tom, not running theExcel instance, but the existance of the installed program I need to check. "Tom Ogilvy" wrote in message ... The most trustworthy would be to start it with CreateObject. (or use GetObject which would get an existing running instance if one was up). -- Regards, Tom Ogilvy Jack <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
How to check programmatically whether Excel is installed on computer?
If you're not satisfied with the CreateObject solution (although I can't see
why... perhaps memory resources, perhaps you need to check remotely?) then you could inspect the registry for the existence of the HKEY_CLASSES_ROOT\Excel.Application key. -- Rob van Gelder - http://www.vangelder.co.nz/excel "Jack" <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
How to check programmatically whether Excel is installed on computer?
"Jack" <replyto@newsgroup wrote:
I mean Excel installed, not running. You didn't say what program you want to use to check it, so there's no single answer. In a batch file, you could use the ASSOC command to see if the .XLS file type has a file association. If it doesn't, either Excel is not installed or it was not installed correctly. If it does, either Excel is installed or it has been installed and then uninstalled (I'm not sure whether the uninstall program deletes the entry). Once you know the file association, you can use the FTYPE command to get the path to the executable. C:\Documents and Settings\Administratorassoc .xls .xls=Excel.Sheet.8 C:\Documents and Settings\Administratorftype excel.sheet.8 excel.sheet.8="C:\Program Files\Microsoft Office\Office\EXCEL.EXE" /e This information is also available through the Windows API if you're using VB (or other language that gives you access to the API). As someone has already said, if you want to know whether Excel is actually runnable, you'll have to try to run it. == Jack Hamilton == In the end, more than they wanted freedom, they wanted comfort and security. And in the end, they lost it all - freedom, comfort and security. Edward Gibbons |
How to check programmatically whether Excel is installed on computer?
Tom is exactly right, but since you seem to need more detailed help than Tom
provided.... If Excel is installed, you'll be able to create an instance of the Excel.Application object. If Excel is not installed, you won't be able to create an instance of the Excel.Application object. So....attempt to create an instance of this object and trap for an error (warning: air code). Dim oXLApp As Object On Error Resume Next Set oXLApp = CreateObject("Excel.Application") If oXLApp Is Nothing Then MsgBox "Excel is not installed or is not installed correctly" Else MsgBox "Excel version " & oXLApp.Version & " is installed in '" & oXLApp.Path & "'" End If There are other ways too. For example, you could use the FindExecutable API function to determine which program, if any, is associated with the .XLS extension. This, however, is not foolproof for determining if Excel is installed because other programs could be associated with the .XLS extension. You could also check any of a number of different Registry keys. This also is not reliable because Registry keys are frequently left behind after a program is uninstalled. Both of these alternatives are also more work (i.e. require more code) than just trying to instantiate the object. I think Tom's suggestion of just trying to instantiate the Excel.Application object is the easiest and most reliable means of determining if Excel (or any application that is an Automation server) is installed and, moreover, installed correctly. Mike "Jack" <replyto@newsgroup wrote in message ... Tom, not running theExcel instance, but the existance of the installed program I need to check. "Tom Ogilvy" wrote in message ... The most trustworthy would be to start it with CreateObject. (or use GetObject which would get an existing running instance if one was up). -- Regards, Tom Ogilvy Jack <replyto@newsgroup wrote in message ... I mean Excel installed, not running. |
All times are GMT +1. The time now is 06:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com