Microsoft Word: Word Count Without Headings

I needed to determine the word count for a Microsoft Word document, omitting all the section titles in the document. I brewed up a little VBA code to do the trick. This was built in Word 2010, but will probably work in the newer versions.

Sub WordCountWithoutHeaders()
' (C) 2013 SpringLight,
' You may use this code in any project you wish as long as you leave the copyright notice in place.
Dim WordCountWhole As Long
Dim WordCountTitles As Long
Dim Titles As String
Dim Msg As String

Application.ScreenUpdating = False
WordCountWhole = ActiveDocument.ComputeStatistics(wdStatisticWords, False)
Selection.Find.Style = ActiveDocument.Styles("Heading 1")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
While Selection.Find.Execute()
Titles = Titles & Selection.Text
WordCountTitles = WordCountTitles + Selection.Range.ComputeStatistics(wdStatisticWords)
Selection.EndKey Unit:=wdStory
Application.ScreenUpdating = True
Msg = "Total Word Count: " & WordCountWhole
Msg = Msg & vbCrLf
Msg = Msg & "Heading1 Word Count: " & WordCountTitles
Msg = Msg & vbCrLf
Msg = Msg & "Text Word Count: " & (WordCountWhole - WordCountTitles)
MsgBox Msg
Debug.Print Titles
Debug.Print Msg
End Sub

In my document the titles are all in the “Heading 1” style, so that’s what this code searches for. If your titles are done in another style, or if your titles are done in multiple styles, you can change one line of code to get the desired result:

Selection.Find.Style = ActiveDocument.Styles(“Heading 1”)

I attached this code to a new button that I placed on the Ribbon, so at the touch of the button the word count is performed. I recommend that.

The code at the end dumps all the titles into the Immediate window in the Visual Basic Editor, which you can copy-and-paste into a new Word document to verify the count, if you wish.

What is a mail merge?

Most organizations need to send mass mailings at least once in awhile. Non-profits generally send annual solicitation mailings, newsletters, notices that they send their clients, and/or party invitations. For-profits use mass mailings to market to their customers.

When you need to send out a large quantity of personalized letters, it’s tedious and time-consuming to have to type addresses on individual letters by hand. A “mail merge” automates this process for you. Whether you need to write 50 letters, 500 letters, or 5,000 letters, with a mail merge the steps are the same. You write the letter only one time, and then let the computer automatically “merge” data from your database into individual copies of the letter you wrote.

With a database constructed by SpringLight, your mail merges will be a breeze! Just a couple of clicks and the letters are ready to print. A couple more clicks and the labels or envelopes are ready to go. All that’s left for you to do is stuff the envelopes and apply postage.