A Microsoft Word forum. Microsoft Office Word Forum - WordBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Microsoft Office Word Forum - WordBanter forum » Microsoft Word Newsgroups » Tables
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Word Count on over 7000 word docs



 
 
Thread Tools Display Modes
  #1  
Old February 26th 06, 04:45 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Word Count on over 7000 word docs

How can I extract word count of over 7000 word docs and place the answer in
Excel.

Also need to get the word count of the doc into the doc, how can I do that
automatically for over 7000 docs?

Thanks

Sujal
Ads
  #2  
Old February 26th 06, 09:13 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Word Count on over 7000 word docs

The following will create a new document containing the information that you
can then copy and paste into Excel. It will however include punctuation
marks, etc. in the count:

Dim MyPath As String
Dim MyName As String
Dim source As Document
Dim target As Document
Dim Wordcount As Long

Set target = Documents.Add

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set source = Documents.Open(MyName)
Wordcount = source.Words.Count
source.Range.InsertAfter vbCr & "This document contains " & Wordcount &
" words (including punctuation and paragraph marks)."
target.Range.InsertAfter "The document " & MyName & " contains " &
Wordcount & " words (including punctuation and paragraph marks)." & vbCr
source.Save
source.Close
MyName = Dir
Loop
target.Activate

If you want to exclude punctuation and paragraph marks, the following should
do that, but will take a lot longer:

Dim MyPath As String
Dim MyName As String
Dim source As Document
Dim target As Document
Dim Wordcount As Long

Set target = Documents.Add

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set source = Documents.Open(MyName)
Wordcount =
source.Content.ComputeStatistics(Statistic:=wdStat isticWords,
IncludeFootnotesAndEndnotes:=True)
source.Range.InsertAfter vbCr & "This document contains " & Wordcount &
" words."
target.Range.InsertAfter "The document " & MyName & " contains " &
Wordcount & " words." & vbCr
source.Save
source.Close
MyName = Dir
Loop
target.Activate


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Sujal" wrote in message
...
How can I extract word count of over 7000 word docs and place the answer
in
Excel.

Also need to get the word count of the doc into the doc, how can I do that
automatically for over 7000 docs?

Thanks

Sujal



  #3  
Old February 27th 06, 03:26 AM posted to microsoft.public.word.tables
external usenet poster
 
Posts: n/a
Default Word Count on over 7000 word docs

Thanks Doug! This solved the problem.

Thank again for your help!

Sujal

"Doug Robbins - Word MVP" wrote:

The following will create a new document containing the information that you
can then copy and paste into Excel. It will however include punctuation
marks, etc. in the count:

Dim MyPath As String
Dim MyName As String
Dim source As Document
Dim target As Document
Dim Wordcount As Long

Set target = Documents.Add

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set source = Documents.Open(MyName)
Wordcount = source.Words.Count
source.Range.InsertAfter vbCr & "This document contains " & Wordcount &
" words (including punctuation and paragraph marks)."
target.Range.InsertAfter "The document " & MyName & " contains " &
Wordcount & " words (including punctuation and paragraph marks)." & vbCr
source.Save
source.Close
MyName = Dir
Loop
target.Activate

If you want to exclude punctuation and paragraph marks, the following should
do that, but will take a lot longer:

Dim MyPath As String
Dim MyName As String
Dim source As Document
Dim target As Document
Dim Wordcount As Long

Set target = Documents.Add

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and insert them into the doc
MyName = Dir$(MyPath & "*.*")
Do While MyName ""
Set source = Documents.Open(MyName)
Wordcount =
source.Content.ComputeStatistics(Statistic:=wdStat isticWords,
IncludeFootnotesAndEndnotes:=True)
source.Range.InsertAfter vbCr & "This document contains " & Wordcount &
" words."
target.Range.InsertAfter "The document " & MyName & " contains " &
Wordcount & " words." & vbCr
source.Save
source.Close
MyName = Dir
Loop
target.Activate


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Sujal" wrote in message
...
How can I extract word count of over 7000 word docs and place the answer
in
Excel.

Also need to get the word count of the doc into the doc, how can I do that
automatically for over 7000 docs?

Thanks

Sujal




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill-in field prompts Deb McLellan New Users 7 March 13th 06 08:43 PM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM
How can Word display full path of a file in the title bar? SAsif Microsoft Word Help 1 January 26th 06 04:32 PM
Does Word have a QuickCorrect/Quick Word option like WordPerfect? CW New Users 2 December 20th 05 05:54 PM
In Word, how do I surpress headers and footers on page 2 Bill Microsoft Word Help 1 December 15th 05 06:13 PM


All times are GMT +1. The time now is 07:46 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.