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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How do I create & merge specific data base & master documents? | maggiev | New Users | 2 | January 12th, 2005 11:30 PM |
WordPerfect - copying formatting | Morgan | Page Layout | 1 | January 10th, 2005 05:00 PM |
Pivot Table Access 2000? | Air-ron | General Discussion | 2 | October 29th, 2004 06:19 PM |
Word 2000/2002 - Proper Mail Merge steps for ODBC? | Tony_VBACoder | Mailmerge | 7 | September 2nd, 2004 09:21 PM |
How to run word and pass a mail merge values and fax it to the recipient | Belinda | Mailmerge | 2 | June 13th, 2004 12:49 AM |