在文本框架中查找每行不同的字体

时间:2016-05-10 20:36:57

标签: vba fonts powerpoint-vba

我正在设计一个宏来证明PowerPoint演示文稿,它可以检查幻灯片上的每个文本框/形状,并输出字体类型,大小和颜色。我有它的工作,它将吐出每个形状的字体大小,问题是,当给定形状中每行有多个字体大小。目前,如果例如第一行是Arial 12而下一行是Arial 14,则输出只占第一行,并且说有两行Arial 12

Dim lFindColor As Long
Dim oSl As Slide
Dim oSh As Shape

Dim colorsUsed As String
Dim fontsUsed As String

Dim lRow As Long
Dim lCol As Long

Dim shpFont As String
Dim shpSize As String
Dim shpColour As String


Set oSl = ActiveWindow.View.Slide
Dim x As Integer

    For Each oSh In oSl.Shapes
    '----Shape Check----------------------------------------------------------
        With oSh
            If .HasTextFrame Then
                If .TextFrame.HasText Then
                    For x = 1 To .TextFrame.TextRange.Runs.Count
                        shpFont = shpFont & .TextFrame.TextRange.Font.Name & ", "
                        shpSize = shpSize & .TextFrame.TextRange.Font.Size & ", "
                        shpColour = shpColour & .TextFrame.TextRange.Font.Color.RGB & ", "
                    Next
                End If
            End If
        End With
    Next

如何搜索每一行并给出形状中每条线的字体大小/类型,我该怎么做?

1 个答案:

答案 0 :(得分:2)

您循环遍历.Runs(如果完整TextRange具有相同的方法和属性集,则为子集),但输出整个TextRange的样式属性。请改用.TextFrame.TextRange.Runs(x).Font.Name等。