简体   繁体   中英

Replace font name of a particular character in text in Power Point

I want to find and replace all instances of the grave accent ` with the font named Rupee Forandian

Recently the rupee symbol was launched and there is no keyboard symbol for that...

When I try the excel replace function CRTL + H with the format function, it changes the font of the entire text string, while I want it to change only the grave accent `

I found a solution for Excel, but I need a similar one for Powerpoint 2007.

The VBA used in Excel is:

Sub InsertRupeeForandianSymbol()
  Dim X As Long, Cell As Range
  For Each Cell In Selection
    For X = 1 To Len(Cell.Value)
      If Mid(Cell.Value, X, 1) = "`" Then Cell.Characters(X, 1).Font.Name = "Rupee Foradian"
    Next
  Next
End Sub

In Powerpoint you have to iterate through Shapes to get texts:

Sub InsertRupeeForandianSymbol()
    Dim sl As Slide, sh As Shape, X As Long
    For Each sl In ActiveWindow.Selection.SlideRange
        For Each sh In sl.Shapes
            With sh.TextFrame.TextRange.Characters
                For X = 1 To .Count
                    If .Characters(X, 1).Text = "'" Then .Characters(X, 1).Font.Name = "Rupee Forandian"
                Next
            End With
        Next
    Next
End Sub

This will change font for all currently selected slides. You may change ActiveWindow.Selection.SlideRange to ActivePresentation.Slides and apply to all slides in current presentation.

Easiest way to do this I can think of would be

 Sub InsertRupeeForandianSymbol()
    Dim oSld As Slide
    Dim oShp As Shape
    Dim x As Long
    Dim y As Long

    For Each oSld In ActivePresentation.Slides
     For Each oShp In oSld.Shapes
         For y = 1 To Len(oShp.TextFrame.TextRange)
          If Mid(oShp.TextFrame.TextRange, y, 1) = "`" Then
            oShp.TextFrame.TextRange.Characters(y).Font.Name = "Rupee Foradian"
          End If
         Next y
     Next oShp
    Next oSld
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM