View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Addin out of range error

This works for me

Dim myval As Boolean
Dim addn As AddIn

myval = False
For Each addn In Application.AddIns
If LCase(addn.Name) = "unloaded addin.xla" Then
myval = addn.Installed
Exit For
End If
Next addn
MsgBox myval


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Trux" wrote in message
ups.com...
Thanks in advance for any assistance.

I am having a bit of trouble with add-ins.

I have a macro that, among other things, checks to see if a particular
add-in is installed and loaded into memory in Excel.

The problem is that if the add-in is not registered in the list of
available add-ins in the Tools-Addins menu it errors out in a subscript
out of error range.

I tried a number of ways to trap the error, none of which have been
successful.

Note: My code is neither clean nor pretty.

Examples:
dim myval as boolean

On Error Resume Next
If IsError(Application.AddIns("Unloaded Addin").Installed = True)
Then myval= false
---------------------------------
dim myval as boolean

If IsError(Application.AddIns("Unloaded Addin").Installed = True)
Then GoTo opt_out
' (other code


exit sub

opt_out:
myval = false
'return to main code
---------------------------------

Each of these generates the Run time error '9':Subscript out of range.

Any ideas on how to check this and not generate an error if the addin
isn't listed as "registered" with Excel?