Reply
 
Thread Tools Display Modes
  #1   Report Post  
Donald C. McNeilly
 
Posts: n/a
Default 1200 doc word count doug robbins

Thank you! Thank you! Worked like a charm once the user got his head around
it. Only took 25 minutes. THe total number was a bit of a stunner though,
over 900,000. I did a double check of all the As and came up with 33,000
manual and 43,000 using the macro. Any ideas why this might be? Can always
discount the macro count by 25% but...

Now is there any way of combining docs say all the A into one?

Thanks again

You wrote: "If you put all of the documents in one folder and modify the
string in the
PathToUse statement in the following macro to point to that folder and then
you run this macro, it will count the words in all of the documents. For
1200 documents, I would put the kettle on to boil before you start"


  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

Using the following may give a more accurate count:

Dim i As Long
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document

PathToUse = "C:\Documents\"

'Error handler to handle error generated whenever
'the FindReplace dialog is closed

On Error Resume Next

'Initiate the counter i

i = 0

'Close all open documents before beginning

Documents.Close SaveChanges:=wdPromptToSaveChanges

'Set the directory and type of file to batch process

myFile = Dir$(PathToUse & "*.doc")

While myFile ""

'Open document
Set myDoc = Documents.Open(PathToUse & myFile)

'Increment the counter i with the number of words in the document

i = i + myDoc.BuiltInDocumentProperties(wdPropertyWords)

myDoc.Close SaveChanges:=wdDoNoSaveChanges

'Next file in folder

myFile = Dir$()

Wend

MsgBox "Total number of words is " & i & "."

The issue with combining the documents is to get them in the correct order.
If you have a list of the documents in another document, one to a paragraph,
a macro can be used to iterate through that list, opening each document in
turn, and then inserting its content into another documnet after the
previous document that was inserted there.

The following code should do it:

Dim source As Document, target As Document, listdoc As Document
Dim i As Long
Dim myFile As Range
Dim PathToUse As String

PathToUse = "C:\Documents\test\"

'listdoc is the document that contains the list of the other documents
'Start with that document open
Set listdoc = ActiveDocument
'Open a new document
Set target = Documents.Add
For i = 1 To listdoc.Paragraphs.Count
Set myFile = listdoc.Paragraphs(i).Range
myFile.End = myFile.End - 1
Set source = Documents.Open(PathToUse & myFile.Text)
target.Range.Select
Selection.Collapse wdCollapseEnd
Selection.FormattedText = source.Range
source.Close wdDoNotSaveChanges
Next i


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"Donald C. McNeilly" wrote in message
...
Thank you! Thank you! Worked like a charm once the user got his head
around it. Only took 25 minutes. THe total number was a bit of a stunner
though, over 900,000. I did a double check of all the As and came up with
33,000 manual and 43,000 using the macro. Any ideas why this might be? Can
always discount the macro count by 25% but...

Now is there any way of combining docs say all the A into one?

Thanks again

You wrote: "If you put all of the documents in one folder and modify the
string in the
PathToUse statement in the following macro to point to that folder and
then
you run this macro, it will count the words in all of the documents. For
1200 documents, I would put the kettle on to boil before you start"



  #3   Report Post  
Robert M. Franz
 
Posts: n/a
Default

Hi Doug

Doug Robbins wrote:
[..]
The issue with combining the documents is to get them in the correct order.
If you have a list of the documents in another document, one to a paragraph,
a macro can be used to iterate through that list, opening each document in
turn, and then inserting its content into another documnet after the
previous document that was inserted there.

[..]

Such a list would most likely be compiled with a simple dir-statement
with the appropriate sorting switch, which sends the file directory into
a text file. Now, with 1200 documents, I assume there is a naming
convention in place where you really *can* sort the files inorder
automatically ...

HTH
Robert
--
/"\ ASCII Ribbon Campaign | MS
\ / | MVP
X Against HTML | for
/ \ in e-mail & news | Word
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
need to count word total for 1200 documents Donald C. McNeilly Formatting Long Documents 2 January 15th 05 01:54 PM
In typing dates in Word, i.e. "January 12" how do you keep the "1. Carol Microsoft Word Help 2 January 12th 05 08:09 PM
word xp crashes after macros are recorded kharris0405 Microsoft Word Help 3 January 11th 05 10:50 PM
WP Delay Code - Word Equiv Mike G - Milw, WI Microsoft Word Help 6 January 10th 05 04:12 PM
macro in word js Microsoft Word Help 1 December 28th 04 03:01 AM


All times are GMT +1. The time now is 03:18 PM.

Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
Copyright 2004-2023 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"