使用VBA在Power Point 2007文本框中移动文本

时间:2015-08-06 13:42:15

标签: vba code-formatting powerpoint-vba

我需要在所有文本框中移动文本的位置(每张幻灯片1个文本框)。字幕'第一语言是白色,英语是黄色。现在我想要黄色在上面,白色在下面。所以首先我要选择白色,复制,擦除,到黄色和粘贴结束(白色/黄色之间有换行符)。可以吗?

对这样的脚本进行一些更改会有所帮助吗?

Sub RemoveWhiteText()

    Dim oSl As Slide
    Dim oSh As Shape


    With ActivePresentation

For Each oSl In .Slides
    For Each oSh In oSl.Shapes
        With oSh
            If .HasTextFrame Then
                If .TextFrame.HasText Then
                    If TextRange.Font.Color = vbWhite Then
                        oSh.TextFrame.Text
                    End If
                End If
            End If
        End With
    Next
Next

    End With
End Sub

1 个答案:

答案 0 :(得分:0)

这会将第一次使用字体颜色白色移动到文本框的末尾。 试试这个:

Sub MoveWhiteTextToEnd(oSh As Shape) With oSh With oSh.TextFrame.TextRange.Runs(1) If .Font.Color.RGB = vbWhite Then .Cut oSh.TextFrame.TextRange.InsertAfter (vbCrLf) oSh.TextFrame.TextRange.Characters(oSh.TextFrame.TextRange.Length + 1).Paste End If End With End With End Sub

使用此调用更新您的代码:

If .TextFrame.HasText Then Call MoveWhiteTextToEnd(oSh) End If

相关问题