how to know if a xla is 'loaded'

  • Thread starter Thread starter Isabelle Robin
  • Start date Start date
I

Isabelle Robin

Hi to all,

I search how to know if an a reference to a xla file is active, in a xls
file.

Do you have some advice ?

thks a lot
 
Hi Isabelle,

There is an addins collection that you can test. This returns all addins
available to Excel, so you need to test the installed property, like so

For Each oai In Application.AddIns
If oai.Installed = True Then
Debug.Print oai.Name
End If
Next


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi,

In fact I have created a xla file and now an excel file has a reference to
this xla file.
With your code, I only see (I think) the installed addins.
But with my xla file, I have done nothing so I can't see it.
The goal is that some people, when they will have access to this xla file,
will have all buttons visible, instead of other people, if they don't have
this xla file, some button will be invisible.
So my question could me : how can I know the checked references in the Tools
menu.

thanks for your answer
 
If you want to know whether an XLA file has been opened either by the addin
manager or some other means use

Dim oAdd as workbook
set oAdd=nothing
on error resume next
set oadd=workbooks("Myaddin.XLA")
on error goto 0
if oadd is nothing then msgbox "Myaddin.xla not loaded"

If you want to know what references are to the XLA are valid in the VBE you
need to add a reference to the VBA extensibility library and look at the
references property of your project

regards
Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm
 
Hi to all,

I found the solution :

Private Sub Workbook_Open()
If CommonExist("common") Then
MsgBox "common exists"
Else
MsgBox "comon doesn't exists"
End If
End Sub

Function CommonExist(refName As String)
CommonExist = False
For Each objReferences In Workbooks("1.xls").VBProject.References
If LCase(objReferences.Name) = refName Then
CommonExist = True
End If
Next objReferences
End Function

Best regards
 
Isabele,

You might want to add some error handling in case the workbook doesn't
exist, but more importantly, if you downshift one side of a test, you should
also downshift the other side

Function CommonExist(refName As String)
Dim objReferences
CommonExist = False
On Error GoTo exit_function
For Each objReferences In Workbooks("1.xls").VBProject.References
If Err.Number = 0 Then
If LCase(objReferences.Name) = LCase(refName) Then
CommonExist = True
End If
End If
Next objReferences
exit_function:
End Function

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top