0
votes

I'm designing a macro to proof PowerPoint presentations that checks each text box/shape on a slide, and outputs the font type, size and colour. I have it working to the point that it will spit out the font size for each shape, the problem is that when there are multiple font sizes per line in a given shape. Currently, if for example the first line is Arial 12 and the next line is Arial 14, the output simply takes the first line, and say that there are two lines of 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

What can I do to search each line and give me the font sizes/type for each individual line within a shape?

1

1 Answers

2
votes

You're looping through the .Runs (which are subsets if the full TextRange with the same set of methods and properties) but outputting the style properties for the whole TextRange. Use .TextFrame.TextRange.Runs(x).Font.Name etc. instead.