Option Explicit
Private Sub Workbook_Open()
Dim Refs As VBIDE.References, R As VBIDE.Reference, TChem(), N As Long, Ns As Long
On Error Resume Next
TChem = [TFPOL]
If Err Then ReDim TChem(1 To 2)
On Error GoTo 0
Set Refs = ThisWorkbook.VBProject.References
Set R = Refs("Outlook") ' Sous toutes réserves
If R.IsBroken Then
Refs.Remove R
For N = 1 To UBound(TChem)
If VarType(TChem(N)) = vbString Then
If Dir(TChem(N)) <> "" Then
Refs.AddFromFile TChem(N)
Exit Sub
End If: End If: Next N
MsgBox "Impossible de corriger automatiquement la référence à Outlook." _
& vbLf & "Veuillez la corriger manuellement", vbInformation
Else
Ns = UBound(TChem) + 1
For N = 1 To UBound(TChem)
If VarType(TChem(N)) = vbString Then
If R.FullPath = TChem(N) Then Exit Sub
Else: Ns = N: End If: Next N
If Ns > UBound(TChem) Then ReDim Preserve TChem(1 To Ns)
TChem(Ns) = R.FullPath
ThisWorkbook.Names.Add "TFPOL", TChem
End If
End Sub