小编Vin*_*kde的帖子

Powerpoint VBA,For Each循环期间的形状删除会跳过下一项

我正在浏览Powerpoint幻灯片1中的形状

当名称为“ HD”的形状被删除时,下一个形状将变为“ SD”,跳过“ 4K”。如果删除了“ 4K”,则下一个形状变为“ FullHD”

如何避免这种情况?

For Each pshape In ppres.Slides(1).Shapes
    Select Case pshape.Name
        Case "HD"
            Debug.Print vbTab & pshape.Name
            If LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) <> "hd" And LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) = "" Then
                pshape.Delete
            End If
        Case "4K"
            Debug.Print vbTab & pshape.Name
            If LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) <> "4k" And LCase(Cells(2, titleHeader.ListColumns("Nature of Material*").Index)) = "" Then
                pshape.Delete
            End If
        Case "SD"
            Debug.Print vbTab & pshape.Name
        Case "FullHD"
            Debug.Print vbTab & pshape.Name
            Debug.Print vbTab & Cells(2, …
Run Code Online (Sandbox Code Playgroud)

excel powerpoint vba powerpoint-vba

1
推荐指数
1
解决办法
59
查看次数

标签 统计

excel ×1

powerpoint ×1

powerpoint-vba ×1

vba ×1