代码之家  ›  专栏  ›  技术社区  ›  Albert Godfrind

如何将演示文稿中的样式替换为其他样式?

  •  0
  • Albert Godfrind  · 技术社区  · 8 年前

    我有很多演示,在这里我展示代码示例。每门课都是一门课。

    我不是很系统:在一些演示中,我使用 menlo 风格。在其他我用的 consolas . 我有时也会在同一个演示中混合使用这两种方法。坏,坏我!

    我现在想让一切更加一致。我的惩罚是在每次演讲中浏览每一张幻灯片来改变风格。

    但是,有没有办法使这种变化全球化呢?我的意思是,有没有一种方法可以在全球范围内替换演示文稿中的样式?在多个演示中?

    1 回复  |  直到 8 年前
        1
  •  1
  •   Steve Rindsberg    8 年前

    这是一个开始:

    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