Albert Godfrind
Albert Godfrind

Reputation: 2078

How can I replace a style in a presentation with another one?

I have a number of presentations where I show code examples. Each one is a lesson in a course.

I have not been very systematic: in some presentations I use the menlo style. In others I use consolas. I also sometimes mix both in the same presentation. Bad, bad me!

I now would like to make everything more consistent. Going through each and every slide in every presentation to change the style is my punishment.

But is there a way to make that change global ? I mean is there a way to replace a style globally in a presentation ? In multiple presentations ?

Upvotes: 0

Views: 40

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

Here's a starter:

Option Explicit

' Edit these to reflect the names of the fonts
' you want to change from and to:
Const ChangeFromFont As String = "Consolas"
Const ChangeToFont As String = "Courier New"

Sub ChangeFontName()

    Dim oSh As Shape
    Dim oSl As Slide

    For Each oSl In ActivePresentation.Slides
    For Each oSh In oSl.Shapes
        If oSh.HasTextFrame Then
        If oSh.TextFrame.HasText Then
            With oSh.TextFrame.TextRange
                If UCase(.Font.Name) = UCase(ChangeFromFont) Then
                    .Font.Name = ChangeToFont
                End If
            End With
        End If
        End If
    Next
    Next

End Sub

Upvotes: 1

Related Questions