VIX
New Member
I am trying to write a macro in Powerpoint which will allow the user to select a font and apply the font to all slides. Currently the code requires the user to input the font name manually but I need it to display the list of fonts available from which the user can select required font. The current code is below
Code:
Sub TextFonts()
Dim oSl As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim lRow As Long
Dim lCol As Long
Dim sFontName As String
' Edit this as needed:
sFontName = InputBox("Select the font")
With ActivePresentation
For Each oSl In .Slides
For Each oSh In oSl.Shapes
With oSh
If .HasTextFrame Then
If .TextFrame.HasText Then
.TextFrame.TextRange.Font.Name = sFontName
End If
End If
End With
Next
Next
End With
For Each s In ActivePresentation.Slides
For Each oSh In s.Shapes
If oSh.HasTable Then
Set oTbl = oSh.Table
For lRow = 1 To oTbl.Rows.Count
For lCol = 1 To oTbl.Columns.Count
With oTbl.Cell(lRow, lCol).Shape.TextFrame.TextRange
.Font.Name = sFontName
End With
Next
Next
End If
Next ' Shape
Next s
End Sub
Last edited by a moderator: