ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Checking for missing references (https://www.excelbanter.com/excel-programming/330154-checking-missing-references.html)

fred

Checking for missing references
 
I have an addin that references a third party dll but it is not always
installed on the target machine.
I simply want to be able to disable any of my menu items and buttons that
use the dll if it is not installed.
In the workbook open event, how can I find out if the dll is installed.

Thanks for any help
Fred



Robin Hammond[_2_]

Checking for missing references
 
Fred,

This should give you an idea of how to test for an object. I've done it
using word, but you should be able to tweak it for a generic dll
(referencing the class in the dll). Do not set a reference to the dll in
question in the project, or it will spit the dummy when the project loads if
the dll is not there. Instead tweak this to try and create the object, and
if you can't, disable the menus in question.

Option Explicit
Option Private Module

Private Sub TestForObject()
MsgBox ObjectExists("Word.Application")
End Sub

Private Function ObjectExists(strObject As String) As Boolean
Dim objTest As Object
On Error Resume Next
Set objTest = GetObject(, strObject)
If Not objTest Is Nothing Then
ObjectExists = True
Else
Set objTest = CreateObject(strObject)
If Not objTest Is Nothing Then
ObjectExists = True
objTest.Quit 'specific to word, may not be needed with a dll
Set objTest = Nothing
End If
End If
On Error GoTo 0
End Function

Robin Hammond
www.enhanceddatasystems.com

"Fred" <leavemealone@home wrote in message
...
I have an addin that references a third party dll but it is not always
installed on the target machine.
I simply want to be able to disable any of my menu items and buttons that
use the dll if it is not installed.
In the workbook open event, how can I find out if the dll is installed.

Thanks for any help
Fred






All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com