打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PPT 批量删除 红色文字

1.首先WPS打开 PPT 中的 VBA 编辑器,

2.无VB编辑器,当前WPS没有安装VB,

网上下载 WPS VB安装包:Visual Basic for Application


VBA 代码如下:

Sub FindAndDeleteTextWithFormat()

    Dim sld As Slide

    Dim shp As Shape

    For Each sld In ActivePresentation.Slides

        For Each shp In sld.Shapes

            If shp.Type = msoGroup Then

               DeleteEmptyTextInGroupShape shp

            ElseIf shp.HasTable Then

                DeleteEmptyTextInTable shp

            ElseIf shp.HasTextFrame And shp.TextFrame.HasText Then

                DeleteEmptyTextInShape shp

           End If

         Next

    Next sld

End Sub

Function DeleteEmptyTextInGroupShape(oSh As Shape)

' Please make sure oSh is a group shape

    Dim oGpSh As Shape

    For Each oGpSh In oSh.GroupItems

        If oGpSh.Type = msoGroup Then

           DeleteEmptyTextInGroupShape oGpSh

        ElseIf oGpSh.HasTable Then

           DeleteEmptyTextInTable oGpSh

        ElseIf oGpSh.HasTextFrame And oGpSh.TextFrame.HasText Then

           DeleteEmptyTextInShape oGpSh

        End If

    Next

End Function

Function DeleteEmptyTextInTable(oSh As Shape)

' Please make sure oSh is a table

    Dim oTabSh As Table

    Dim lRow As Long

    Dim lCol As Long

    If oSh.HasTable Then

       Set oTabSh = oSh.Table

       For lRow = 1 To oTabSh.Rows.Count

           For lCol = 1 To oTabSh.Columns.Count

               DeleteEmptyTextInShape oTabSh.Cell(lRow, lCol).Shape

           Next lCol

       Next lRow

     End If

End Function

Function DeleteEmptyTextInShape(oSh As Shape)

' Please make sure oSh contains text

    If Not (oSh.HasTextFrame And oSh.TextFrame.HasText) Then

       Exit Function

    End If

    Dim i As Long

    With oSh.TextFrame.TextRange

        For i = .Characters.Count To 1 Step -1

             If .Characters(i, 1).Font.Color = vbRed Then

                .Characters(i, 1).Text = ""

            End If

        Next

    End With

End Function

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
批量修改ppt中所有字的字体颜色
ppt批量删除备注
【PPT】如何将大小为24的字瞬间变成大小40?
VBA专题01:操作形状的VBA代码
给你的PPT来剂“减肥神药”吧
最简单的C#快速入门教程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服