Count words with computeStatistics

F

FotoArt

hello everyone

Im trying to select the text in a section
count the number of words(without using readabilityStatictics.value(1)
put it in the header
SO far I have comeup with the following code which gets error at the 4th
line.

Sub bbb()
Dim lngWords As Long

ActiveDocument.Bookmarks("\section").Select
lngWords = ActiveDocument.Selection.Range.ComputeStatistics(wdStatisticWords)
ActiveDocument.Bookmarks("fff").Select
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertAfter Text:=lngWords
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="fff"
ActiveWindow.Panes(2).Close

End Sub

Any help would be appreciated

thanx
ahmed
 
F

FotoArt

It ok I have bee able to work it out this way.
it may not be the very efficient.
Sub bbb()
Dim lngWords As Long

ActiveDocument.Bookmarks("\section").Select
'lngWords = ActiveDocument.Range.ComputeStatistics(wdStatisticWords)
lngWords =
ActiveDocument.Bookmarks("\section").Range.ComputeStatistics(wdStatisticWords)
ActiveDocument.Bookmarks("fff").Select
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.InsertAfter Text:=lngWords
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="fff"
ActiveWindow.Panes(2).Close
 

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