Public Function ReplaceInternationalCharacters(ByVal strText As String) As String
Dim i As Integer
'Big A
For i = 192 To 197
ReplaceInternationalCharacters = Replace(strText, Chr(i), "A")
Next i
'little A
For i = 224 To 229
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "a")
Next i
'Big E
For i = 200 To 203
ReplaceInternationalCharacters = Replace(strText, Chr(i), "E")
Next i
'little e
For i = 232 To 235
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "e")
Next i
'Big I
For i = 204 To 207
ReplaceInternationalCharacters = Replace(strText, Chr(i), "I")
Next i
'little i
For i = 236 To 239
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "i")
Next i
'Replace Big O
For i = 210 To 216
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "O")
Next i
'Replace little o
For i = 242 To 248
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "o")
Next i
'Replace Big U
For i = 217 To 220
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "O")
Next i
'Replace little u
For i = 249 To 252
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(i), "o")
Next i
'Replace Big Y
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(152), "y")
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(236), "y")
'Replace Big N
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(209), "N")
'Replace little N
ReplaceInternationalCharacters = Replace(ReplaceInternationalCharacters, Chr(241), "n")
End Function
Public Function ReplaceSpecialCharacters(ByVal strText As String, Optional ReplaceChar As String = "_")
Dim i As Integer
ReplaceSpecialCharacters = strText
ReplaceSpecialCharacters = Replace(ReplaceSpecialCharacters, "'", "''")
ReplaceSpecialCharacters = Replace(ReplaceSpecialCharacters, "#", "_No_")
For i = 1 To 31
ReplaceSpecialCharacters = Replace(ReplaceSpecialCharacters, Chr(i), "_")
Next i
For i = 126 To 231
ReplaceSpecialCharacters = Replace(ReplaceSpecialCharacters, Chr(i), "_")
Next i
End Function
Public Function ReplaceUnicodeCharacters(txt As String) As String
Dim regEx As Object
Set regEx = CreateObject("vbscript.regexp")
regEx.Pattern = "[^\u0000-\u007F]"
ReplaceUnicodeCharacters = regEx.Replace(txt, "~")
End Function
Public Function ReplaceBadCharacters(ByVal strtxt As String) As String
ReplaceBadCharacters = strtxt
ReplaceBadCharacters = ReplaceInternationalCharacters(ReplaceBadCharacters)
ReplaceBadCharacters = ReplaceSpecialCharacters(ReplaceBadCharacters)
ReplaceBadCharacters = ReplaceUnicodeCharacters(ReplaceBadCharacters)
End Function