Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA - Find and Replace a character

140 views
Skip to first unread message

Mel

unread,
Nov 19, 2009, 5:07:51 PM11/19/09
to
(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

Shyam Pillai

unread,
Nov 19, 2009, 6:46:38 PM11/19/09
to
Hello,
Take a look at this example and then adapt it to your needs.
http://skp.mvps.org/ppt00025.htm#2

Regards,
Shyam Pillai

Image Importer Wizard: http://skp.mvps.org/iiw.htm


"Mel" <mel....@yahoo.com> wrote in message
news:fc01e139-9cd1-4990...@s31g2000yqs.googlegroups.com...

Mel

unread,
Nov 20, 2009, 10:31:33 AM11/20/09
to
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


On Nov 19, 5:46 pm, "Shyam Pillai" <ShyamPil...@Gmail.com> wrote:
> Hello,

> Take a look at this example and then adapt it to your needs.http://skp.mvps.org/ppt00025.htm#2


>
> Regards,
> Shyam Pillai
>
> Image Importer Wizard:http://skp.mvps.org/iiw.htm
>

> "Mel" <mel.tu...@yahoo.com> wrote in message

Mel

unread,
Nov 20, 2009, 1:08:25 PM11/20/09
to
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

Steve Rindsberg

unread,
Nov 20, 2009, 3:22:07 PM11/20/09
to
In article <2c0eb7c9-606a-471f-b9b3-

827cdc...@k4g2000yqb.googlegroups.com>, Mel wrote:
> 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?

Chr$(8482) gives me an error message.

Try ChrW$() instead of Chr$()


>
> Thanks,
> Melina
>
> On Nov 19, 5:46 pm, "Shyam Pillai" <ShyamPil...@Gmail.com> wrote:
> > Hello,
> > Take a look at this example and then adapt it to your needs.http://skp.mv
> ps.org/ppt00025.htm#2
> >
> > Regards,
> > Shyam Pillai
> >
> > Image Importer Wizard:http://skp.mvps.org/iiw.htm
> >
> > "Mel" <mel.tu...@yahoo.com> wrote in message
> >
> > news:fc01e139-9cd1-4990...@s31g2000yqs.googlegroups.com...
> >
> > > (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


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


Mel

unread,
Nov 20, 2009, 3:33:06 PM11/20/09
to
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

On Nov 20, 2:22 pm, Steve Rindsberg <ab...@localhost.com> wrote:
> In article <2c0eb7c9-606a-471f-b9b3-

Steve Rindsberg

unread,
Nov 20, 2009, 10:34:15 PM11/20/09
to
In article <fb9523d1-66c6-49f8...@s31g2000yqs.googlegroups.com>,
Mel wrote:
> THAT DID IT!!!

WooHOO! Intuition strikes the right place once in a while.

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

The Chr$() function is supposed to be able to accept a Long as an argument, but
it only returns a single-byte character, so anything over 255 is a) meaningless
and b) will throw an error.

ChrW$() returns a "wide" (unicode/multi-byte) character, which is what you're
after. Note that you can still run into weirdness if you ask for values > 255 in
text formatted in a single-byte font.

>
> Thanks so much, Steve!!!
>
> -Melina
>
> On Nov 20, 2:22 pm, Steve Rindsberg <ab...@localhost.com> wrote:
> > In article <2c0eb7c9-606a-471f-b9b3-
> >
> > 827cdc6e1...@k4g2000yqb.googlegroups.com>, Mel wrote:
> > > 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?
> >
> > Chr$(8482) gives me an error message.
> >
> > Try ChrW$() instead of Chr$()
> >
> >
> >
> >
> >
> > > Thanks,
> > > Melina
> >
> > > On Nov 19, 5:46 pm, "Shyam Pillai" <ShyamPil...@Gmail.com> wrote:
> > > > Hello,
> > > > Take a look at this example and then adapt it to your needs.http://sk
> p.mv
> > > ps.org/ppt00025.htm#2
> >
> > > > Regards,
> > > > Shyam Pillai
> >
> > > > Image Importer Wizard:http://skp.mvps.org/iiw.htm
> >
> > > > "Mel" <mel.tu...@yahoo.com> wrote in message
> >

> > > >news:fc01e139-9cd1-4990...@s31g2000yqs.googlegroups.com....


> >
> > > > > (PPT 2003 and sometimes 2007)
> >
> > > > > Hi, again.
> >
> > > > > Within every object on each of my slides, I want to replace Chr$(84
> 82)
> > > > > 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
> >
> > ========================
> ======
> > PPT Frequently Asked Questionshttp://www.pptfaq.com/
> >
> > PPTools add-ins for PowerPointhttp://www.pptools.com/

0 new messages