How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask Greg Maxey Your Own Question
Greg Maxey
Greg Maxey, Consultant\Microsoft Word Expert
Category: General
Satisfied Customers: 62
Experience:  Microsoft Word Most Valuable Professional (6 years)
Type Your Question Here...
Greg Maxey is online now
A new question is answered every 9 seconds

Ask a Microsoft Word Question How do I count the total number

This answer was rated:

Ask a Microsoft Word Question
>How do I count the total number of words in 14 documents that are all in a single in I have 14 individual docx files that comprise a can I figure out the total word count for the total project without opening each document and counting and then adding 14 numbers up?

Each document will have to be opened. You can do it with a VBA procedure:

Option Explicit

Public Sub BatchCountWords()
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim lngWordCount As Long
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
'Get the folder containing the files
With 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 open
If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
myFile = 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$()
MsgBox lngWordCount
End 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.

Greg Maxey and 48 other General Specialists are ready to help you

Related General Questions