Function RemoveCharAccents(ByVal TextToChange As String, Optional ByVal ToUpperCase As Boolean = False)
'Permet de substituer les accents d'un chaîne avec option MAJUSCULE
Const CHARS_WITH_ACCENTS As String = _
"ÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖØÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöøùúûüýÿ"
'"ÀÁÂÃÄÅÈÉÊËÌÍÎÏÒÓÔÕÖØÙÚÛÜàáâãäåèéêëìíîïòóôõöøùúûüÿÑÇñç"
Const CHARS_WITHOUT_ACCENTS As String = _
"AAAAACEEEEIIIINOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy"
'"AAAAAAEEEEIIIIOOOOOOOUUUUaaaaaaeeeeiiiioooooouuuuyNCnc"
Dim c As Integer
Dim strChar As String
Dim strNoAccentChars As String
Dim strFinalString As String
strFinalString = TextToChange
strNoAccentChars = CHARS_WITHOUT_ACCENTS
If ToUpperCase Then
strNoAccentChars = UCase$(CHARS_WITHOUT_ACCENTS)
End If
For c = 1 To Len(CHARS_WITH_ACCENTS)
strChar = Mid$(CHARS_WITH_ACCENTS, c, 1)
If InStr(1, strFinalString, strChar, vbBinaryCompare) Then
strFinalString = Replace(strFinalString, strChar, Mid$(strNoAccentChars, c, 1))
End If
Next c
RemoveCharAccents = IIf(ToUpperCase, UCase(strFinalString), strFinalString)
End Function