VBA程序 在PPT中使用宏命令删除空白的文本框

打开PPT,切换到视图菜单下,点击宏,输入宏的名称(如clear),点击创建。进入命令窗口,复制以下命令编译执行即可。

Sub clear()
Dim found As Boolean
Dim textflag As Boolean
Dim trng As TextRange
Do
found = False
For Each Sld In ActivePresentation.Slides
    For Each shp In Sld.Shapes
     If shp.HasTextFrame Then
        textflag = False
        If shp.TextFrame.HasText Then
        Set trng = shp.TextFrame.TextRange
            For i = trng.Characters.Count To 1 Step -1
            If trng.Characters(i) <> " " Then
                textflag = True
                Exit For
            End If
            Next
         End If
         If shp.Type <> 1 Then
            If Not shp.TextFrame.HasText Or textflag = False Then
            ActiveWindow.View.GotoSlide Index:=shp.Parent.SlideIndex
            shp.Select
            shp.Delete
            found = True
            End If
         End If
    End If
    Next shp
Next Sld
Loop While found = True
End Sub

注意:上面的宏名称是clear,可以改成自己喜欢的名字。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值