如何用另一个样式替换演示文稿中的样式?

时间:2018-07-18 08:59:19

标签: powerpoint powerpoint-vba

我有很多演示,其中展示了代码示例。每个课程都是一门课程。

我还不是很系统:在某些演示中,我使用menlo风格。在其他情况下,我使用consolas。有时我还会在同一演示文稿中将两者混在一起。不好,我不好!

我现在想使所有内容更加一致。浏览每个演示文稿中的每张幻灯片以更改样式是我的惩罚。

但是有没有办法使这种改变成为全球性的呢?我的意思是,有一种方法可以在演示文稿中全局替换样式吗?在多个演示中?

1 个答案:

答案 0 :(得分:1)

这是一个开始:

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