View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default excel missing library

You can't remove a library if you need it.

If you need it, you should make provision for having it.

If you don't need it, you shouldn't have a reference to it.

this should be resolved prior to distributing the application.

If your problem is with different versions of Excel, then you should develop
in the lowest version of excel that will use the file.

If your problem is with an additional reference (version problems), then you
should use late binding.

http://support.microsoft.com/default.aspx?kbid=245115
INFO: Using Early Binding and Late Binding in Automation

http://support.microsoft.com/default...b;EN-US;247579
INFO: Use DISPID Binding to Automate Office Applications Whenever Possible



--
Regards,
Tom Ogilvy

"Joel" wrote in message
...
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