WordCount Problem

G

Guest

hi,

Please excuse if I am in wrong group.

Given following code fragment-

--------------------------------------------
Words oWords = m_oDoc.GetWords();

long num = m_oDoc.ComputeStatistics(wdStatisticWords,
COleVariant(long(FALSE)));

*NumWords = oWords.GetCount();

if(*NumWords)
{
for(long i = 1; i<= (*NumWords); i++)
{
Range word = oWords.Item(i);
TRACE( word.GetText() );
Sleep( 100 );
WRITE_2_LOG_FILE_STRING( word.GetText() );
}
}
----------------------------------------------------------------

I am trying to "process" a word document word by word. Why does here in
above two function calls -

1. ComputeStatistics
2. Words.GetCount()

ms word returns different count of words?

ComputeStatistics return the same count as I get from the Tools->WordCount
menu option, but GetCount() seams to be counting "many things" other then
words. like ----

Given following URL as only text in a document [minus quotes]:

"http://support.microsoft.com/kb/178749"

ComputeStatistics counts it as 1 word but GetCount returns 11

My Second Question is how do I "tell" the oWords.Item(i) Method to give me
words in "way ComputeStatistics method takes/counts" and "not the way
GetCount Method takes"...?

My intentention is to save a few processor cycle when processing the
document "word by word"
 
D

Daiya Mitchell

You are in the wrong group.

Look for one with Word and VBA in the name, or Word and Programming. You'll
get more and faster help with code there.


hi,

Please excuse if I am in wrong group.

Given following code fragment-

--------------------------------------------
Words oWords = m_oDoc.GetWords();

long num = m_oDoc.ComputeStatistics(wdStatisticWords,
COleVariant(long(FALSE)));

*NumWords = oWords.GetCount();

if(*NumWords)
{
for(long i = 1; i<= (*NumWords); i++)
{
Range word = oWords.Item(i);
TRACE( word.GetText() );
Sleep( 100 );
WRITE_2_LOG_FILE_STRING( word.GetText() );
}
}
----------------------------------------------------------------

I am trying to "process" a word document word by word. Why does here in
above two function calls -

1. ComputeStatistics
2. Words.GetCount()

ms word returns different count of words?

ComputeStatistics return the same count as I get from the Tools->WordCount
menu option, but GetCount() seams to be counting "many things" other then
words. like ----

Given following URL as only text in a document [minus quotes]:

"http://support.microsoft.com/kb/178749"

ComputeStatistics counts it as 1 word but GetCount returns 11

My Second Question is how do I "tell" the oWords.Item(i) Method to give me
words in "way ComputeStatistics method takes/counts" and "not the way
GetCount Method takes"...?

My intentention is to save a few processor cycle when processing the
document "word by word"
 

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