Vba 更改Powerpoint中带下划线的文本字体

Vba 更改Powerpoint中带下划线的文本字体,vba,powerpoint,Vba,Powerpoint,我有一个大的PPT文件,我需要格式化为某些规格。我需要所有字体为Arial 14,除非文本有下划线。如果文本带下划线,我需要字体为32。这是我迄今为止的尝试,我已经使用了Arial 14部分,但我不知道如何只选择带下划线的文本。如果有人有任何想法,我们将不胜感激。除此之外,我对VBA也没有任何经验,尽管我熟悉c++ Sub use() Dim s As Slide Dim shp As Shape For Each s In ActivePresentation.Slides For Each

我有一个大的PPT文件,我需要格式化为某些规格。我需要所有字体为Arial 14,除非文本有下划线。如果文本带下划线,我需要字体为32。这是我迄今为止的尝试,我已经使用了Arial 14部分,但我不知道如何只选择带下划线的文本。如果有人有任何想法,我们将不胜感激。除此之外,我对VBA也没有任何经验,尽管我熟悉c++

Sub use()
Dim s As Slide
Dim shp As Shape

For Each s In ActivePresentation.Slides
For Each shp In s.Shapes
    If shp.HasTextFrame Then
        With shp
        .TextFrame.TextRange.Font.Name = "Arial"
        .TextFrame.TextRange.Font.Size = 14
            If .TextFrame.TextRange.Font.Underline = True Then
                .TextFrame.TextRange.Font.Size = 32
            End If
            With .TextFrame.TextRange
             .ParagraphFormat.SpaceBefore = 0
             End With

        End With

        End If
    Next shp
Next s
End Sub
试试这个

Sub Sample()
    Dim oSl As Slide
    Dim oSh As Shape
    Dim x As Long

    For Each oSl In ActivePresentation.Slides
        For Each oSh In oSl.Shapes
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    For x = 1 To Len(oSh.TextFrame.TextRange.Text)
                        If oSh.TextFrame.TextRange.Characters(x, 1).Font.Underline = True Then
                            With oSh.TextFrame.TextRange.Characters(x, 1)
                                .Font.Size = 32
                            End With
                        End If
                    Next
                End If
            End If
        Next
    Next
End Sub
截图