Thread: able to find
View Single Post
 
Old 01-27-2022, 02:18 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Based on code from Finding and replacing symbols the following will replace the alpha and beta characters with Times New Roman font. The font size is set to 14 so you can easily see that the font has been replaced. If that works for you delete the two font size lines. You can add any other Greek characters to the array as required.
Code:
Sub Macro1()
Dim vFindText As Variant
Dim i As Integer
    vFindText = Array(ChrW(-3999), ChrW(-3998))
    For i = 0 To UBound(vFindText)
        Call FindSymbols(FindChar:=CStr(vFindText(i)), FindFont:="Symbol")
    Next i
End Sub

Sub FindSymbols(FindChar As String, FindFont As String)

Dim FoundFont As String, OriginalRange As Range, strFound As Boolean
    Application.ScreenUpdating = False
    Set OriginalRange = Selection.Range
    strFound = False
    With Selection.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Text = FindChar
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False

        Do While .Execute    'Keep going until nothing found
            If Dialogs(wdDialogInsertSymbol).Font = FindFont Then
                strFound = True
                Selection.Font.Name = "Times New Roman"
                Selection.Font.Size = 14
            Else
                Selection.Collapse 0
            End If
            strFound = False
        Loop

        If Not strFound Then
            'if nothing found, search from the beginning of the document
            ActiveDocument.Range(0, 0).Select
            Do While .Execute
                If Dialogs(wdDialogInsertSymbol).Font = FindFont Then
                    Selection.Font.Name = "Times New Roman"
                    Selection.Font.Size = 14
                    strFound = True
                Else
                    Selection.Collapse 0
                End If
                strFound = False
            Loop
        End If

    End With

    OriginalRange.Select

    Set OriginalRange = Nothing
    Application.ScreenUpdating = True

End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote