E
Ed
Is there a function that counts the number of times a particular character
appears within a selection? Thanks.
Ed (in Virginia)
appears within a selection? Thanks.
Ed (in Virginia)
Ed said:Is there a function that counts the number of times a particular character
appears within a selection? Thanks.
Karl E. Peterson said:Get the selection into a string (I'm not an object model guy; I just do
code <g>), 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
Ed said: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
Roy said:Sorry, but same error. Apparently the XML coding is sticking into the mix
the very character that I am trying to count. Works fine in XP and 2003
documents. Fails with XML (2007) documents.
Ed said: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)?
Karl E. Peterson said:(Is this a bug in Word2007)?
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.