Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 01-27-2022, 02:18 AM
gmayor's Avatar
gmayor gmayor is offline able to find Windows 10 able to find Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
able to find Find What Text (^&) is not working for find Italic formatted strings Mercurial Word 5 06-29-2021 05:20 PM
How do you use the find and replace tool to find dates and times in Excel 2013? Jules90 Excel 3 04-14-2020 07:40 PM
find IP in range / find number between numbers gn28 Excel 4 06-14-2015 03:46 PM
able to find Find what box in Find and replace limits the length of a search term Hoxton118 Word VBA 7 06-10-2014 05:05 AM
able to find Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:20 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft