Ask Experts & Get Answers to Your Questions - ASAP
Each document will have to be opened. You can do it with a VBA procedure:
Public Sub BatchCountWords()Dim myFile As StringDim PathToUse As StringDim myDoc As DocumentDim lngWordCount As LongDim fDialog As FileDialogSet fDialog = Application.FileDialog(msoFileDialogFolderPicker)'Get the folder containing the filesWith fDialog .Title = "Select Folder containing the documents to be modified and click OK" .AllowMultiSelect = False .InitialView = msoFileDialogViewList If .Show <> -1 Then MsgBox "Cancelled By User", , "Batch Count Words" Exit Sub End If PathToUse = fDialog.SelectedItems.Item(1) If Right(PathToUse, 1) <> "\" Then PathToUse = PathToUse + "\"End With'Close any documents that may be openIf Documents.Count > 0 Then Documents.Close SaveChanges:=wdPromptToSaveChangesEnd IfmyFile = Dir$(PathToUse & "*.doc")While myFile <> "" 'Open each file and count the words. Set myDoc = Documents.Open(PathToUse & myFile) lngWordCount = lngWordCount + myDoc.ComputeStatistics(wdStatisticWords) 'Close the file, saving the changes. myDoc.Close SaveChanges:=wdDoNotSaveChanges myFile = Dir$()WendMsgBox lngWordCountEnd Sub
Paste the above code in a standard module of your Normal template. The execute the code.
Press Alt+F11 to open the VB Editor. If not showing, press CTRL+r to display the project explorer. Scroll down and expand the Normal project. Using the insert menu insert a standard code module. Dbl-click the new module and paste the code into the large empty code panel on the right. On the menu click Run then Run Macro.
Thank you for the opportunity to assit you with your Word issue. Please note that this question required programing that would have taken considerable time and effort had I not already had something that was close.