I wrote a code to ask user input a fontname and then use VBA to search the whole presentation for shapes that bears this font and replace to another.
However, my code somehow doesn't work. I figure the reason is this line "If sh.TextFrame.TextRange.Font.Name = searchFont Then" The fontname return from the user input is just text, but this line need it to be within " ". (eg. "Arial")
if anyone has a solution to this, please kindly help me. Thanks in advance
Sub ReplaceFont()
Dim sld As Slide
Dim sh As Shape
Dim searchFont As String
searchFont = InputBox("Please enter font to search.", "Font Search Function")
On Error Resume Next
For Each sld In ActivePresentation.Slides
For Each sh In sld.Shapes
If sh.HasTextFrame = True Then
If sh.TextFrame.HasText = True Then
If Ucase(sh.TextFrame.TextRange.Font.Name) = Ucase(searchFont) Then
With sh.TextFrame.TextRange.Font
.Name = "Arial"
End With
End If
End If
End If
Next
Next
End Sub