Lonely
Nov 23rd, 2003, 11:38 PM
Hi,
I have been trying to make a search/replacement macro for PowerPoint. I have been using the replacement function defined by Microsoft for the purpose (given below).
However, I noticed that if the PowerPoint Presentation includes a Table, then replacements are not performed on these. I have been trying to access the cell contents for the purpose but havent really been successfull. For the timebeing I am ungrouping the table and converting them to shapes and then performing the replacements (see code below).
I have included some of the codes i have been using in my program below.
Please can someone help me in writing a code which can access the text in a cell in a table. I have been able to wite something as shown below, but without success. :(
************************
With ActivePresentation.Slides(2).Shapes(4).Table
.Cell(2, 1).Shape.TextFrame.TextRange.Text = "Replace this"
End With
************************
Thanks,
Lonely
*******Replace (Code Start)***********
Sub ReplaceText()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="like", _
Replacewhat:="NOT LIKE", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="like", _
Replacewhat:="NOT LIKE", WholeWords:=True)
Loop
Next oShp
End Sub
*******Replace (Code End)***********
I have been trying to make a search/replacement macro for PowerPoint. I have been using the replacement function defined by Microsoft for the purpose (given below).
However, I noticed that if the PowerPoint Presentation includes a Table, then replacements are not performed on these. I have been trying to access the cell contents for the purpose but havent really been successfull. For the timebeing I am ungrouping the table and converting them to shapes and then performing the replacements (see code below).
I have included some of the codes i have been using in my program below.
Please can someone help me in writing a code which can access the text in a cell in a table. I have been able to wite something as shown below, but without success. :(
************************
With ActivePresentation.Slides(2).Shapes(4).Table
.Cell(2, 1).Shape.TextFrame.TextRange.Text = "Replace this"
End With
************************
Thanks,
Lonely
*******Replace (Code Start)***********
Sub ReplaceText()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides
For Each oShp In oSld.Shapes
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:="like", _
Replacewhat:="NOT LIKE", WholeWords:=True)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length, _
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:="like", _
Replacewhat:="NOT LIKE", WholeWords:=True)
Loop
Next oShp
End Sub
*******Replace (Code End)***********