What you're trying to replace is accents, not diacritics.
Not sure what you've got against a function. For example:
Code:
Sub Test()
MsgBox RemoveAccents("Túró") 'This is just an example
End Sub
Function RemoveAccents(StrNm As String) As String
Dim i As Long, ArrFnd, ArrRep
ArrFnd = Array("À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", _
"Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "Ø", "Ù", "Ú", "Û", _
"Ü", "Ý", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", _
"í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "ÿ")
ArrRep = Array("A", "A", "A", "A", "A", "A", "AE", "C", "E", "E", "E", "E", _
"I", "I", "I", "I", "D", "N", "O", "O", "O", "O", "O", "O", "U", "U", "U", _
"U", "Y", "a", "a", "a", "a", "a", "a", "ae", "c", "e", "e", "e", "e", "i", _
"i", "i", "i", "o", "n", "o", "o", "o", "o", "o", "o", "u", "u", "u", "u", "y", "y")
For i = 0 To UBound(ArrFnd)
StrNm = Replace(StrNm, ArrFnd(i), ArrRep(i))
Next
RemoveAccents = StrNm
End Function
Sure, it could be done without a function, but having a function makes it easier to call from anywhere in your code - and is more portable than something hard-coded into a sub.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
|