分享

如何用vba给ppt幻灯片中的同类型的图形批量重命名?

 Zenliber 2019-11-15
2018年12月5日作者:exceloffice
46 次浏览暂无评论

如下图所示

ppt幻灯片中有6个矩形,名称分别为”矩形 N”的形式,现在想要批量将其名称换成”img N”的形式,可以使用如下的vba代码:

Visual Basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Sub QQ1722187970()
    Dim oPPT As Presentation
    Dim oSlide As Slide
    Dim oCL As CustomLayout
    Dim oP As Shape
    '当前ppt演示文稿
    Set oPPT = PowerPoint.ActivePresentation
    With oPPT
        '遍历每一个幻灯片
        For Each oSlide In .Slides
            i = 1
            With oSlide
                '遍历每一个图形
                For Each oP In .Shapes
                    With oP
                        sName = .Name
                        iType = .Type
                        If sName Like "*矩形*" Then
                            sName = "img" & i
                            .Name = sName
                            i = i + 1
                        End If
                    End With
                Next
            End With
        Next
    End With
End Sub

结果如下图所示:

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多