• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Font change code with list of fonts

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:
Back
Top