Group: microsoft.public.word.vba.general
From: "Ed"
Date: Friday, March 14, 2008 5:48 AM
Subject: Re: Counting occurence of specific character in selection

Karl (or others):

I am trying to count "forward slashes". "/"

The routine you suggested works perfectly in Word2003. And it works
perfectly in Word2007 if there are no images. But if there are images within
the selected text, the images get counted as a slash, messing up the count.
Is there another technique? (Is this a bug in Word2007)?

Example: Texttexttext/(image1)Texttexttext2/(image2)Texttexttext3

Ed (in Virginia)

"Karl E. Peterson" wrote in message
news:OVoIYTVhIHA.4740@TK2MSFTNGP05.phx.gbl...
> Ed wrote:
>> Is there a function that counts the number of times a particular
>> character
>> appears within a selection? Thanks.
>
> Get the selection into a string (I'm not an object model guy; I just do
> code ), then something like this oughta tell ya:
>
> TheCount = UBound(Split(Selection, TheChar))
>
> For example:
>
> ?ubound(split("l;kjwet;kew", "c"))
> 0
> ?ubound(split("abcabcabcab", "c"))
> 3
>
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>


Safety Articles | Usenet Groups | Usenet News | Bluegrass