marathi.bana
02-27-2009, 03:58 PM
I want to creat macro for ReplaceAll. I got code from help.
Code:
Sub ReplaceText()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
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
But this code not replace all the 'like'.
Example:
1) I like mangoes and I like apple and I like orange
2) I like India and I like US and I like UK
3) I like Cricket and I like Football and I like Tennis
When I run the above macro, I get output as follows
1) I NOT LIKE mangoes and I NOT LIKE apple and I NOT LIKE orange
2) I like India and I like US and I NOT LIKE UK
3) I like Cricket and I like Football and I like Tennis
All the 'like' not replace by 'not like'
Can somebody help me to create macro to replace all the 'like' in the sentence as well as in whole presentation.
The output should be
1) I NOT LIKE mangoes and I NOT LIKE apple and I NOT LIKE orange
2) I NOT LIKE India and I NOT LIKE US and I NOT LIKE UK
3) I NOT LIKE Cricket and I NOT LIKE Football and I NOT LIKE Tennis
I want to replace all "like" just in single click.
Can you please help me? :(
Thanks
Code:
Sub ReplaceText()
Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Set oSld = Application.ActivePresentation.Slides(1)
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
But this code not replace all the 'like'.
Example:
1) I like mangoes and I like apple and I like orange
2) I like India and I like US and I like UK
3) I like Cricket and I like Football and I like Tennis
When I run the above macro, I get output as follows
1) I NOT LIKE mangoes and I NOT LIKE apple and I NOT LIKE orange
2) I like India and I like US and I NOT LIKE UK
3) I like Cricket and I like Football and I like Tennis
All the 'like' not replace by 'not like'
Can somebody help me to create macro to replace all the 'like' in the sentence as well as in whole presentation.
The output should be
1) I NOT LIKE mangoes and I NOT LIKE apple and I NOT LIKE orange
2) I NOT LIKE India and I NOT LIKE US and I NOT LIKE UK
3) I NOT LIKE Cricket and I NOT LIKE Football and I NOT LIKE Tennis
I want to replace all "like" just in single click.
Can you please help me? :(
Thanks