'
Function NombreEnLettre(chain As String, Optional decimale As Long = 2) As String
Dim t, dixx&, dix&, cxx&, u&, uL
uL = Array("", "un", "deux", "trois", "quatre", "cinq", "six", "sept", "huit", "neuf", "dix", "onze", "douze", "treize", "quatorze", "quinze", "seize", "dix-sept", "dix-huit", "dix-neuf", "cent ")
Diz = Array("", "dix", "vingt", "trente", "quarante", "cinquante", "soixante", "soixante-dix", "quatre-vingt", "quatre-vingt-dix", "cent")
ms = Array("", " decilliard", " decillion", " nonilliard", " nonillion", " octillard", " octillion", " septilliard", " septillion", " sextilliard", " sextillion", " quintilliard ", " Quintillion", " quadrilliard", " quadrillion", " trilliard", " trillion", " Billiard", " billion", " milliard", " million", " mille", "")
x = UBound(ms)
t = Split(chain, ",")
If UBound(t) > 0 And Val(t(1)) = 0 Then t = Array(t(c))
For c = 0 To UBound(t)
chaine = t(c)
If c = 0 Then chaine = "00" & t(c)
If c = 1 Then chaine = "0" & Left(chaine & "0000", decimale): If Len(chaine) > 4 Then chaine = Left(chaine, 4)
Z = 0
For i = Len(chaine) - 2 To 1 Step -3
Z = Z + 1: seg = Mid(chaine, i, 3)
cxx = Left(seg, 1): dixx = Right(seg, 2): dix = Mid(seg, 2, 1): u = Right(seg, 1)
If cxx = 1 Then cxx = 20: cc = "" Else cc = IIf(cxx > 0, "-cents ", "")
If dix = 9 Or dix = 7 And u >= 1 Then dix = dix - 1: u = u + 10
If dixx > 9 And dixx < 20 Then dix = 0: u = u + 10
If dix >= 2 And dix <= 7 And (u = 1 Or u = 11) Then et = " et " Else et = IIf(dix <> 0, IIf(u <> 0, "-", " "), " ")
If Val(seg) = 0 Then ms(UBound(ms) - Z + 1) = ""
If Z = 2 And Val(seg) = 1 Then uL(1) = ""
If c = 0 Then entier = Application.Trim(Application.Trim(uL(cxx) & cc & Diz(dix) & et & uL(u)) & " " & ms(x) & IIf(Val(seg) > 1 And Z > 2, "s", "") & " " & entier)
uL(1) = "un"
If c > 0 Then dec = dec & "," & Application.Trim(Application.Trim(uL(cxx) & cc & Diz(dix) & et & uL(u)))
x = x - 1
Next
Next
NombreEnLettre = Replace(entier & dec, " ", "-")
End Function