View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joel Joel is offline
external usenet poster
 
Posts: 1
Default excel missing library

Hi ! everybody

I try to find a way to repear effects of missing library when a workbook
travel from an environnement to another one.

Of course, I don't want to do it manualy, but automatically.

I've found some procedures but they don't seems to work finely :

for instance : why do that one don't work ?
Don't matter with french strings...

The .Name and .FullPath Properties can't be read if the library is missing !
The library can't be removed if missing !

How can we remove a missing library ?

Thank's a lot for answers ! and sorry for language errors

'=======================
Sub AddMissingRefs()
'examine les références d'un projet, repère celles qui
'sont déclarées manquantes et essaye de les réinstaller

Dim LesRefs As Object, i&, Msg$, Cpt&, Rep&, Mnq&, Chemin$, Nom$

Set LesRefs = ThisWorkbook.VBProject.References
For i = 1 To LesRefs.Count
With LesRefs(i)
If .IsBroken Then
Mnq = Mnq + 1: Chemin = .FullPath: Nom = .Name
LesRefs.Remove LesRefs.Item(.Name)
If Dir(Chemin) = "" Then
Msg = "La librairie " & Nom & " est manquante et le fichier" &
vbLf
Msg = Msg & "'" & Chemin & "'" & vbLf
Msg = Msg & "ne peut être trouvé pour l'installer."
MsgBox Msg, vbCritical
Cpt = Cpt + 1
Else
LesRefs.AddFromFile Chemin
Rep = Rep + 1
End If
End If
End With
Next i

If Mnq 0 Then
If Cpt 0 Then Msg = Cpt & " référence(s) toujours manquante(s)"
If Rep 0 Then Msg = Msg & Rep & "référence(s) réinstallée(s)"
End If

End Sub

'================================



--

Bien cordialement,

Joël GARBE
www.joelgarbe.fr