Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check is Excel is Installed 1

Status
Not open for further replies.
Jan 9, 2003
147
US
Hi,

I have a function in Access that exports data to Excel using the Excel 9.0 Object library. Is there a way to test if a machine has a specific Office application installed? It would be nice to be able to disable the Export to Excel function if Excel does not exist! :)

Also, is there a way to programatically disable the reference to the object library if Excel does not exist?

Maybe I just answered my own question...will the Access app generate an error on startup if the correct Excel library is not there...can I then trap this error and add/remove the reference through code?


Thanks,
Andrew
 
You may consider to reference the Microsoft Visual Basic for Applications Extensibility 5.3.
Then in your object browser take a look at VBIDE, References, Reference and IsBroken.
You may have security issue when you manipulate a VBA project.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
FirstDivision

As an OEM reseller I can safely say that is a client has MS Access installed they will have Excel installed as you would actually have to disable it during install and I see no good reason for someone doing that mate.


-----------------
Cogito Ergo Sum
-----------------
 
Thanks PHV, those look very promising. I'll have to play around with those objects. Then I'll have to test it on a machine that has Access but not Excel, which as Harlequin said, are very hard to come by. :)

Thanks guys,
Andrew
 
IMO the safest way to test is the following...

Code:
Public Function GetExcelVersion() as String

  On Error Resume Next
  
  Dim oXLA as Object

  err.Clear
  Set oXLA = CreateObject("Excel.Application")

  If err.Number<>0 Then
    GetExcelVersion = "NOT INSTALLED"
  Else
    GetExcelVersion = oXLA.Version()
  End If

  Set oXLA = Nothing
 
End Function

By using CreateObject you don't need a module reference set so the program won't error out with some obscure "Can't find object or library" if Excel doesn't exist.

HtH,

Rob

-Focus on the solution to the problem, not the obstacles in the way.-
 
I like it Rob! And it follows the KISS principle as well.

Thanks,
Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top