簡體   English   中英

在Powerpoint VBA中檢查多個形狀

[英]Checking Multiple Shapes in Powerpoint VBA

提前致謝。

我要檢查幻燈片(B01-B44)上的44個形狀,以查看它們是否不包含字母“ A”。 我還想從搜索中排除其他形狀。 我想在沒有很多“ and”的情況下執行此操作,但是我對VBA還是有些陌生。

就像是:

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

您可以循環執行此操作:

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

注意:這將檢查文本是否為 “ A”,而不是是否包含字母“ A”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM