Share via

How to set text font, size, and color in a macro

Donald Ray 60 Reputation points
2026-03-01T15:58:50.44+00:00

I want to set the text font, size, and color of a rectangle named "Loser" into which text will be entered.

The Loser rectangle is on the last slide.

The button to enter the text in Loser is on the first slide 1.

I have added losingTeam = "TEAM1" as an example.

SetLoser enteres "TEAM1" in the losingTeam rectangle, however the text font and size are not Impact 60.

Please advise what I am doing wrong.

Sub SetLoser() 

Dim resultsSlide As Slide

Dim resultsSlideIndex As Integer

Dim losingTeam As String



losingTeam = "TEAM 1"

resultsSlideIndex = ActivePresentation.Slides.count

Set resultsSlide = ActivePresentation.Slides(resultsSlideIndex)

resultsSlide.Shapes("Loser").TextFrame.TextRange.Font.name = Impact

resultsSlide.Shapes("Loser").TextFrame.TextRange.Font.Size = 60

resultsSlide.Shapes("Loser").TextFrame.TextRange.Font.Color.RGB = RGB(255, 192, 0)

resultsSlide.Shapes("Loser").TextFrame.TextRange.Text =losingTeam

End Sub

Mod moved from : Microsoft 365 and Office | PowerPoint | For home | Windows

Developer technologies | Visual Basic for Applications
0 comments No comments

Answer accepted by question author
  1. Q&A Assist
    2026-03-01T15:58:59.1766667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Use a string for the font name and set the font properties before or after assigning the text; the key issue is that Impact must be quoted.

    Change this line:

    resultsSlide.Shapes("Loser").TextFrame.TextRange.Font.name = Impact
    

    to:

    resultsSlide.Shapes("Loser").TextFrame.TextRange.Font.Name = "Impact"
    

    A cleaned-up version of the macro:

    Sub SetLoser()
        Dim resultsSlide As Slide
        Dim resultsSlideIndex As Integer
        Dim losingTeam As String
    
        losingTeam = "TEAM 1"
        resultsSlideIndex = ActivePresentation.Slides.Count
        Set resultsSlide = ActivePresentation.Slides(resultsSlideIndex)
    
        With resultsSlide.Shapes("Loser").TextFrame.TextRange
            .Text = losingTeam
            .Font.Name = "Impact"
            .Font.Size = 60
            .Font.Color.RGB = RGB(255, 192, 0)
        End With
    End Sub
    

    This sets the text, font name, size, and color for the entire text range of the shape named "Loser" on the last slide.


    References:

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.