简体   繁体   English

在Powerpoint VBA中检查多个形状

[英]Checking Multiple Shapes in Powerpoint VBA

thanks in advance. 提前致谢。

I have 44 shapes on a slide (B01 - B44) that I want to check to see if they DO NOT contain the letter "A". 我要检查幻灯片(B01-B44)上的44个形状,以查看它们是否不包含字母“ A”。 There are other shapes that I want to exclude from the search. 我还想从搜索中排除其他形状。 I would like to do this without a bunch of "and"s but I'm somewhat new to VBA. 我想在没有很多“ and”的情况下执行此操作,但是我对VBA还是有些陌生。

Something like: 就像是:

If ActivePresentation.Slides(2).Shapes("B##").TextFrame.TextRange.Text <> "A" Then MsgBox "No A's"

You can do this in a loop: 您可以循环执行此操作:

Dim i as Long, a As Long
Dim shp as Shape
Dim pres as Pres: Set  pres = ActivePresentation

For i = 1 to 44
    Set shp = pres.Slides(2).Shapes("B" & i)
    If shp.TextFrame.TextRange.Text <> "A" Then
        aCount = aCount+1
    End If
Next

If aCount = 0 Then 
    MsgBox "No A's were found"
Else:
    MsgBox aCount & " A's were found"
End If

Note: This checks to see if the text is "A", not whether it contains the letter "A". 注意:这将检查文本是否为 “ A”,而不是是否包含字母“ A”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM