Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-26-2012, 05:12 PM
cyberpaper cyberpaper is offline Word count in multiple documents Windows XP Word count in multiple documents Office 2003
Novice
Word count in multiple documents
 
Join Date: Oct 2010
Posts: 19
cyberpaper is on a distinguished road
Default Word count in multiple documents

I want to compare a large number of documents, in different folders, to see their word counts.

So far, using several different search methods and programs, all I've been able to do is come up with lists of docs that show each doc's size in kilobytes. This isn't accurate enough because the kb count is 'rounded'.

Ideally, I could institute a search for *.doc and have the result show every document's word total.

Anyone know a way of doing this?

I'm running XPP and Word 2003. Search apps I've tried are 'Search Everything', Agent Ransack and its full version, File Locator Pro.
Reply With Quote
  #2  
Old 07-26-2012, 08:16 PM
Charles Kenyon Charles Kenyon is offline Word count in multiple documents Windows Vista Word count in multiple documents Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

This will require a vba procedure (macro) that I am not competent to write. It is not something built into Word. See duplicate post at http://answers.microsoft.com/en-us/o...1425d207#_self
There is nothing wrong with asking the same question in multiple locations, but please let people know about the other spot to avoid duplication of effort.
Reply With Quote
  #3  
Old 07-26-2012, 11:46 PM
macropod's Avatar
macropod macropod is offline Word count in multiple documents Windows 7 64bit Word count in multiple documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You could try a macro like the following in an empty document:
Code:
Sub GetWordCounts()
Application.ScreenUpdating = False
Dim strFolder As String, strFile As String, wdDoc As Document
Dim Rng As Range, Shp As Shape, iShp As InlineShape, i As Long
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.doc", vbNormal)
While strFile <> ""
  Set wdDoc = Documents.Open(FileName:=strFolder & "\" & strFile, AddToRecentFiles:=False, Visible:=False)
  With wdDoc
    i = 0
    'Get word counts from the document body, endnotes, & footnotes
    For Each Rng In .StoryRanges
      Select Case .Type
        Case wdMainTextStory, wdEndnotesStory, wdFootnotesStory
          i = i + Rng.ComputeStatistics(wdStatisticWords)
      End Select
    Next
    'Get word counts from textboxes, etc. in the document body
    For Each Shp In .Shapes
      With Shp
        If Not .TextFrame Is Nothing Then
          i = i + .TextFrame.TextRange.ComputeStatistics(wdStatisticWords)
        End If
      End With
    Next
    For Each iShp In .InlineShapes
      With iShp
        i = i + .Range.ComputeStatistics(wdStatisticWords)
      End With
    Next
    .Close SaveChanges:=False
  End With
  ThisDocument.Range.InsertAfter strFile & vbTab & i & vbCr
  strFile = Dir()
Wend
Set wdDoc = Nothing
Application.ScreenUpdating = True
End Sub
 
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function
The macro has its own folder browser, which lets you choose the folder to process. The output, in the document holding the macro, consists of the document names and their word counts.

Note 1: The macro only processes one folder at a time.
Note 2: The macro processes the document body, endnotes, footnotes and textboxes in the document body (not in headers & footers); you can omit any of the first three you might not be interested in by editing the line -
Case wdMainTextStory, wdEndnotesStory, wdFootnotesStory
and, for textboxes, etc., by omitting the corresponding For Each ... Next loops.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 07-27-2012, 07:45 AM
Charles Kenyon Charles Kenyon is offline Word count in multiple documents Windows Vista Word count in multiple documents Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

When run on a folder that contains primary merge documents, the procedure is interrupted to confirm links. When run on a folder that contains no word documents nothing is returned.

I made the mistake of putting these in a module in my normal.dotm. It put the text into normal.dotm (as you said it would). Changing ThisDocument to ActiveDocument eliminated that problem. I was worried that ActiveDocument might be the document being counted, but it was the document that was open when I ran the macro.
Reply With Quote
  #5  
Old 07-27-2012, 03:05 PM
macropod's Avatar
macropod macropod is offline Word count in multiple documents Windows 7 64bit Word count in multiple documents Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

hi Charles,

You could reduce the interruption issues by adding:
Application.DisplayAlerts = False
after:
Application.ScreenUpdating = False

The lack of output for a folder containing no documents is as I would expect - the macro is only coded to report documents.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 07-27-2012, 07:31 PM
Charles Kenyon Charles Kenyon is offline Word count in multiple documents Windows Vista Word count in multiple documents Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,082
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Thanks, this isn't something I have any use for, but I was interested in the code and really like your folder picker.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
search on multiple word documents Guy Roth Word 7 03-06-2017 01:31 PM
Word count in multiple documents How can I count multiple usage of the same words? coffee_king Word VBA 1 03-24-2012 07:52 PM
Word 2010 / Master Index / Multiple Documents bawrites Word 0 08-09-2011 11:02 AM
Word count in multiple documents How to count multiple values in a single cell, except zero? iuliandonici Excel 1 04-13-2011 09:45 PM
Word count in multiple documents Count with multiple conditions bundy5150 Excel 4 02-22-2011 10:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:14 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft