hi

the property App.Characters.Count seems to give the no of
chars + special chars like carraige return - i know how to
parse the document and remove those chars from the count -
but i was wondering if there was an easier way to
determine the no of chars with spaces - same as the menu
Tools/Word count returns.

The fn i use now is ( is there a better implmentation for
it?):
' counts chars and words in txt
' char are spaces but not special chars like carraige
return (chr13)
' params:1. txt As String - the text to count chars in
'Output: int of char count
Function cntChar(txt As String) As Integer
Dim i1 As Integer, i As Integer, d
wordCnt = 0


i1 = 0
' could have white space after white space so flag
'white space = char 13 or space
Dim inWord As Boolean
For i = 1 To Len(txt)
If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
Sheets(4).Range("b14").Value & "."

d = Mid(txt, i, 1)

If (Asc(d) > 30) Then
i1 = i1 + 1
End If
If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
inWord Then
wordCnt = wordCnt + 1
inWord = False
ElseIf (Asc(d) > 32) And Not inWord Then
inWord = True
End If

If deBg Then d = Asc(d)


Next
cntChar = i1
'Return

End Function

Re: character count by Larry

Larry
Fri Feb 20 15:45:35 CST 2004

Tushar,

Your message would be a lot easier to read without all the abbreviated
words and the lack of capitalization. You may think that writing "no"
for "number" and "txt" for "text" and "fn" for I don't know what and
also not capitalizing any words makes it easier for you to write the
message--but it makes it harder for other people to read it. That's why
there's a common language with a common spelling. People use the same
language with the same spelling so that they can communicate with each
other.

Larry



tushar wrote:
> hi
>
> the property App.Characters.Count seems to give the no of
> chars + special chars like carraige return - i know how to
> parse the document and remove those chars from the count -
> but i was wondering if there was an easier way to
> determine the no of chars with spaces - same as the menu
> Tools/Word count returns.
>
> The fn i use now is ( is there a better implmentation for
> it?):
> ' counts chars and words in txt
> ' char are spaces but not special chars like carraige
> return (chr13)
> ' params:1. txt As String - the text to count chars in
> 'Output: int of char count
> Function cntChar(txt As String) As Integer
> Dim i1 As Integer, i As Integer, d
> wordCnt = 0
>
>
> i1 = 0
> ' could have white space after white space so flag
> 'white space = char 13 or space
> Dim inWord As Boolean
> For i = 1 To Len(txt)
> If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
> Sheets(4).Range("b14").Value & "."
>
> d = Mid(txt, i, 1)
>
> If (Asc(d) > 30) Then
> i1 = i1 + 1
> End If
> If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
> inWord Then
> wordCnt = wordCnt + 1
> inWord = False
> ElseIf (Asc(d) > 32) And Not inWord Then
> inWord = True
> End If
>
> If deBg Then d = Asc(d)
>
>
> Next
> cntChar = i1
> 'Return
>
> End Function



Re: character count by Jezebel

Jezebel
Fri Feb 20 15:59:51 CST 2004

activedocument.BuiltInDocumentProperties(wdPropertyCharsWSpaces)


"tushar" <tgkprog6@hotmail.com> wrote in message
news:1355601c3f7d1$dfc856e0$a301280a@phx.gbl...
> hi
>
> the property App.Characters.Count seems to give the no of
> chars + special chars like carraige return - i know how to
> parse the document and remove those chars from the count -
> but i was wondering if there was an easier way to
> determine the no of chars with spaces - same as the menu
> Tools/Word count returns.
>
> The fn i use now is ( is there a better implmentation for
> it?):
> ' counts chars and words in txt
> ' char are spaces but not special chars like carraige
> return (chr13)
> ' params:1. txt As String - the text to count chars in
> 'Output: int of char count
> Function cntChar(txt As String) As Integer
> Dim i1 As Integer, i As Integer, d
> wordCnt = 0
>
>
> i1 = 0
> ' could have white space after white space so flag
> 'white space = char 13 or space
> Dim inWord As Boolean
> For i = 1 To Len(txt)
> If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
> Sheets(4).Range("b14").Value & "."
>
> d = Mid(txt, i, 1)
>
> If (Asc(d) > 30) Then
> i1 = i1 + 1
> End If
> If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
> inWord Then
> wordCnt = wordCnt + 1
> inWord = False
> ElseIf (Asc(d) > 32) And Not inWord Then
> inWord = True
> End If
>
> If deBg Then d = Asc(d)
>
>
> Next
> cntChar = i1
> 'Return
>
> End Function
>



Re: character count by Klaus

Klaus
Fri Feb 20 16:05:04 CST 2004

> [...] same as the menu Tools/Word count returns.


Hi Tushar,

(ActiveDocument)
.BuiltInDocumentProperties(wdPropertyPages)
.BuiltInDocumentProperties(wdPropertyWords)
.BuiltInDocumentProperties(wdPropertyCharacters)
.BuiltInDocumentProperties(wdPropertyCharsWSpaces)
.BuiltInDocumentProperties(wdPropertyParas)
.BuiltInDocumentProperties(wdPropertyLines)

Regards,
Klaus



Re: character count by Peter

Peter
Sat Feb 21 01:15:43 CST 2004

Hi Tushar

If you want info on specific ranges of your document check out the Document
and Range objects ComputeStatistics method.

HTH + Cheers - Peter

"tushar" <tgkprog6@hotmail.com> wrote in news:1355601c3f7d1$dfc856e0
$a301280a@phx.gbl:

> hi
>
> the property App.Characters.Count seems to give the no of
> chars + special chars like carraige return - i know how to
> parse the document and remove those chars from the count -
> but i was wondering if there was an easier way to
> determine the no of chars with spaces - same as the menu
> Tools/Word count returns.
>
> The fn i use now is ( is there a better implmentation for
> it?):
> ' counts chars and words in txt
> ' char are spaces but not special chars like carraige
> return (chr13)
> ' params:1. txt As String - the text to count chars in
> 'Output: int of char count
> Function cntChar(txt As String) As Integer
> Dim i1 As Integer, i As Integer, d
> wordCnt = 0
>
>
> i1 = 0
> ' could have white space after white space so flag
> 'white space = char 13 or space
> Dim inWord As Boolean
> For i = 1 To Len(txt)
> If (i Mod 250) = 0 Then Sheets(4).Range("b14").Value =
> Sheets(4).Range("b14").Value & "."
>
> d = Mid(txt, i, 1)
>
> If (Asc(d) > 30) Then
> i1 = i1 + 1
> End If
> If (Asc(d) = 32 Or Asc(d) = 13 Or Asc(d) = 10) And
> inWord Then
> wordCnt = wordCnt + 1
> inWord = False
> ElseIf (Asc(d) > 32) And Not inWord Then
> inWord = True
> End If
>
> If deBg Then d = Asc(d)
>
>
> Next
> cntChar = i1
> 'Return
>
> End Function
>