how to know if a xla is 'loaded'
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)
"Isabelle Robin" wrote in message
...
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
Isabelle Robin wrote:
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
Bob Phillips wrote:
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)
"Isabelle Robin" wrote in message
...
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
|