Hi,
merci, même en gardant les dates en type "string", ça a marché, en fait, comme il fallait que le programme trouve un nom de fichier toujours le même à la date près, les caractères en type chaîne sont adaptés. Résultat: tout a marché, pour mon projet en tout cas. Après j'ai inséré un boucle et un Go To pour ne pas avoir une boucle infinie.
Voici mon code final:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim var_date As String
1 var_date = InputBox("Veuillez saisir la date du Tableau de Bord sous format AAAA_MM" + Chr(13) + "Tapez EXIT, en majiscule, pour sortir")
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists("\\Server4\DATA1\REVUES-PRJ-INGENIERIE\0-Tableaux_de_bord\TdB-Project_status_report_" & var_date & ".xls") = True Then
'Formules à appliquer....
'...
'...
'...
Range("AG24").FormulaLocal = "='\\Server4\DATA1\REVUES-PRJ-INGENIERIE\0-Tableaux_de_bord\[TdB-Project_status_report_" & var_date & ".xls]1371-Nose Fairing Freighter'!$D$23/1000"
'...
'...
'...
'Periode....
Dim mois, annee, moistxt, affichage As String
mois = Right(var_date, 2)
annee = Left(var_date, 4)
If mois = "01" Then
moistxt = "Janvier"
ElseIf mois = "02" Then
moistxt = "Février"
ElseIf mois = "03" Then
moistxt = "Mars"
ElseIf mois = "04" Then
moistxt = "Avril"
ElseIf mois = "05" Then
moistxt = "Mai"
ElseIf mois = "06" Then
moistxt = "Juin"
ElseIf mois = "07" Then
moistxt = "Juillet"
ElseIf mois = "08" Then
moistxt = "Août"
ElseIf mois = "09" Then
moistxt = "Septembre"
ElseIf mois = "10" Then
moistxt = "Octobre"
ElseIf mois = "11" Then
moistxt = "Novembre"
ElseIf mois = "12" Then
moistxt = "Décembre"
Else
moistxt = "MOIS NON VALIDE!!!"
End If
affichage = moistxt & " " & annee
Range("U3").FormulaLocal = affichage
Else
If var_date = "EXIT" Then
GoTo 2
Else
reponse = MsgBox("LE TDB DE CE MOIS N'EXISTE PAS ou VOUS AVEZ MAL SAISI LE MOIS" + Chr(13) + "Cliquez OK pour recommencer")
GoTo 1
End If
End If
Set fs = Nothing
MsgBox ("Fin du traitement, cliquez OK pour voir le résultat")
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
2 End Sub
Merci encore à tous pour vos conseils.
Reggenzi