VBA - Find and Replace a character

M

Mel

(PPT 2003 and sometimes 2007)

Hi, again.

Within every object on each of my slides, I want to replace Chr$(8482)
for Chr$(9674). I also want it then superscripted, and for it to
change characters in charts and wordart as well. But I'm stuck.
Everything I'm trying is just turning into a mess. Can anyone help
with this?

Thanks a lot,
Melina
 
M

Mel

Thanks. But I can't figure out how can I make this search and replace
a character number such as replace Chr$(8482) with Chr$(9674). Can
this be done?

Thanks,
Melina
 
M

Mel

Can PPT not negotiate such high character numbers? My code works fine
with smaller character numbers. I'm just trying to replace the trade
mark symbol with the lozenge symbol. The numbers I'm using is what PPT
showed in recording a macro of inserting the symbols, so it'd appear
PPT recognizes the character numbers. What am I doing wrong? Do I need
to do something special with such high character numbers? This is what
I'm using...

Sub ReplaceChrs()

Dim oSld As Slide
Dim oShp As Shape
Dim oTxtRng As TextRange
Dim oTmpRng As TextRange
Dim SearchFor As String
Dim ReplaceWith As String
SearchFor = Chr(8482)
ReplaceWith = Chr(9674)

For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.HasText Then
Set oTxtRng = oShp.TextFrame.TextRange
Set oTmpRng = oTxtRng.Replace(FindWhat:=SearchFor, _
Replacewhat:=ReplaceWith, WholeWords:=False)
Do While Not oTmpRng Is Nothing
Set oTxtRng = oTxtRng.Characters(oTmpRng.Start + oTmpRng.Length,
_
oTxtRng.Length)
Set oTmpRng = oTxtRng.Replace(FindWhat:=SearchFor, _
Replacewhat:=ReplaceWith, WholeWords:=False)
Loop
End If
End If
Next oShp
Next oSld

End Sub
 
M

Mel

THAT DID IT!!!

Ok, so can you enlighten me as to what's the difference between the
two (besides one worked and the other didn't.)

Thanks so much, Steve!!!

-Melina
 
Joined
Mar 10, 2014
Messages
1
Reaction score
0
Hi,

Thanks, it helped a lot. But now I do have one more question.

If for example I would like to change ChR(8482) but not Chr(8482), this will not work. How can I do it so that it can see the differences between Capital letteres and not.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top