2 Attachment(s)
Find & replace issue with Greek letter
I am developing a macro to find Greek letters in a normal font and replace them by using the InsertSymbol function with the Symbol font. The macro works fine with all letters except sigma, because this letter has two forms – a regular one "σ", and a final one "ς" for use at the end of words – but the find function is not distinguishing between the two forms.
The following macro loops through a "vFindText" array that should find both forms of the letter and replace them with corresponding characters from the "vReplaceText" array using the InsertSymbol function.
Code:
Sub Macro1()
Dim vFindText As Variant
Dim vReplaceText As Variant
Dim oRng As Range
Dim i As Integer
vFindText = Array(ChrW(963), ChrW(962))
vReplaceText = Array(-3981, -4010)
For i = 0 To UBound(vFindText)
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = vFindText(i)
Do While .Execute
oRng.Select
oRng.InsertSymbol Font:="Symbol", _
CharacterNumber:=vReplaceText(i), _
Unicode:=True
oRng.Collapse 0
Loop
End With
Next i
End Sub
If the macro is run on the attached document #1, the result should be as in the attached document #2, with the two forms of the letter converted separately, but currently it replaces them both with the same form. How can I get the macro to work as specified?
Attachment 30569
Attachment 30570