這將適用於一個通配符;您需要將其更改爲採用參數(您正在搜索的不同通配符文本字符串)或調用另一個例程來輪流搜索每個通配符。但這裏是你如何在單元格中找到文本並根據需要進行着色:
Dim oSl As Slide
Dim oSh As Shape
Dim oTbl As Table
Dim x As Long
Dim y As Long
For Each oSl In ActivePresentation.Slides
For Each oSh In oSl.Shapes
' other code here to check for ## text in the shape
If oSh.HasTable Then
Set oTbl = oSh.Table
With oTbl
For x = 1 To .Rows.Count
For y = 1 To .Columns.Count
With .Cell(x, y)
If InStr(.Shape.TextFrame.TextRange.Text, "##budget##") > 0 Then
.Shape.Fill.ForeColor.RGB = RGB(255, 0, 0)
End If
End With
Next
Next
End With
End If
Next
Next
感謝此示例史蒂夫! 我不知道的是,如果有方法可以識別,在oTbl中是否是一個項目符號列表並在其中標識通配符? – user615993
無論表格單元格中有什麼文字,我都認爲這應該起作用。 oTbl對象本身不能包含文本,只能包含可能包含文本的單元格。 –