Reputation: 185
I must write a program that read some data from SharePoint and write it into a PowerPoint presentation. There are some wildcards in the presentation, like ##budget## which I must replace with the values from SharePoint. This could be done by search and replace into the PowerPoint presentation, I think.
But there are also tables which background must be colored red, green, yellow etc. and I don't know, which options there are to identify the particular tables and the affected cells and which would be the best way to do that.
Upvotes: 0
Views: 743
Reputation: 14809
This would work for one wildcard; you'll want to change it to either take a parameter ( the different wildcard text strings you're searching for ) or to call another routine that searches for each wildcard in turn. But here's how you'd find text in a cell and color it as needed:
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
Upvotes: 1