How to counting words in a string variable?

  • Thread starter Thread starter JS
  • Start date Start date
J

JS

Hi All:
Sorry to ask so many questions - I need to count words, using the
Words.Count Method, in a variable declared as String.
Does anyone know how to do this? I'm being unsuccessful in getting this text
in a TextRange that Words.Counts wants.
Thanks in advance for your help, JS
 
This works for me here.
MsgBox ActiveWindow.Selection.SlideRange.Shapes("Rectangle
3").TextFrame.TextRange.Words.Count

Brian Reilly, MVP
 
Hi All:
Sorry to ask so many questions - I need to count words, using the
Words.Count Method, in a variable declared as String.
Does anyone know how to do this? I'm being unsuccessful in getting this text
in a TextRange that Words.Counts wants.

See Shyam's answer to your earlier post (it's better to keep all of your
messages on a given topic in the same thread, by the way).

His suggestion is that you create a dummy text box and having done that:
(assuming a reference to the text box in oSh)

With oSh.TextFrame.TextRange
.Text = YourString
' do your word count stuff here
End With
oSh.Delete
 
Hi Steve and Shyam:
Steve and Shyam, sorry for posting this question - I thought that since it
was a new question to an answer to another question that it had got lost
under the proverbail stack... my fault... I'm taken back by the so different
way 2000 and 2003 treat the WholeWords parameter in the Replace Method - it
basically ruined all my Find&Replace I've been using for years!
Again, sorry nad thanks for your suggestion.
Rgds, JS
 
Hi Brian,
Thanks for your reply.
Rgds, JS

Brian Reilly said:
This works for me here.
MsgBox ActiveWindow.Selection.SlideRange.Shapes("Rectangle
3").TextFrame.TextRange.Words.Count

Brian Reilly, MVP
 
Hi Steve and Shyam:
Steve and Shyam, sorry for posting this question -

No problem ... that was just a friendly suggestion, not a scold.
 

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

Back
Top