
The Anchorage
Personal website of Gregory K. Maxey, Commander USN (Retired)
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!
The purpose of this Microsoft Word Tips & Microsoft Word Help page is to provide help to the frustrated transcriptionist.
Transcriptionists often ask "How do I get an accurate count of lines in my document that actually contain text?"
The Word command "Word Count" generates a report listing the number of lines in a document. The report qualifies “all lines.” This includes lines that are empty but still available for holding text. There is a difference between an empty line (which is counted) and space between lines, which isn't.

Have a look at the two samples of text below. They both look the same and they both appear to have 6 lines of text.

However, the "Lines" count in a Word Count report of Sample I text returns eight (8). Surely a frustratingly inaccurate count for the transcriptionists.

A line count of the Sample II text returns six (6).

What is the difference? The first example contains empty lines!!
Toggle display of non-printing characters CTRL+SHIFT+* and you will see in the first example the ¶ paragraph symbol marking an empty line 3 and 5. Are these lines capable of holding text? Certainly! Empty lines are a result of undisciplined formatting. It is very easy and generally a bad habit to create space between lines by pressing the enter key. However, as this example has illustrated, you are not only generating space; you are also adding empty paragraphs, which count as lines.

Sample II, on the other, has disciplined paragraph formatting applied using the "Paragraph" dialog. As an alternative, you can quickly apply this formatting to any selected text with the keyboard shortcut CTRL+0.

Disciplined formatting should eliminate most of your problems with accurate line counting. However, if you refuse to get onboard, I have put together a few macros to overcome the error induced by undisciplined formatting.
Option Explicit
Private m_lngUndo As Long
Private m_bUndo As Boolean
Private m_lngOffset As Long
Sub ReportLines()
MsgBox fcnCountLinesOfText(Selection.Range)
MsgBox fcnCountLinesOfText(ActiveDocument.Range)
lbl_Exit:
Exit Sub
End Sub
Function fcnCountLinesOfText(oRng As Range) As Long
Dim oRngUndo As Range
m_lngUndo = 0
m_lngOffset = 0
m_bUndo = False
If oRng.Tables.Count = 0 Then
With oRng.Find
.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[^l^13]{2,}"
.Replacement.Text = "^p"
If .Execute(Replace:=wdReplaceAll) Then
m_bUndo = True
m_lngUndo = 1
End If
End With
DoEvents
fcnCountLinesOfText = oRng.ComputeStatistics(1)
If m_bUndo Then ActiveDocument.Undo
DoEvents
Else
Set oRngUndo = oRng.Duplicate
With oRngUndo.Find
.ClearFormatting
.Format = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Text = "[^l^13]{2,}"
Do While .Execute
m_bUndo = True
m_lngUndo = m_lngUndo + 1
oRngUndo.End = oRngUndo.End - 1
oRngUndo.Delete
oRngUndo.Collapse wdCollapseEnd
Loop
End With
DoEvents
m_lngUndo = m_lngUndo + fcnHandleTables(oRng)
fcnCountLinesOfText = oRng.ComputeStatistics(wdStatisticLines) - m_lngOffset
If m_bUndo Then ActiveDocument.Undo m_lngUndo
DoEvents
End If
lbl_Exit:
Exit Function
End Function
Function fcnHandleTables(oRngEval As Range) As Long
Dim oTbl As Table
Dim oRng As Range
Dim lngUndo As Long
For Each oTbl In oRngEval.Tables
Set oRng = oTbl.Range
oRng.Collapse wdCollapseStart
On Error GoTo Reenter
If oRng.Characters.First.Previous = vbCr Then
If Len(oRng.Characters.First.Previous.Paragraphs(1).Range.Text) = 1 Then
If oRng.Characters.First.Previous.Start = ActiveDocument.Range.Start Then
oRng.Characters.First.Previous.Delete
lngUndo = lngUndo + 1
m_bUndo = True
Else
If Not oRng.Characters.First.Previous.Previous.Information(wdWithInTable) Then
oRng.Characters.First.Previous.Delete
lngUndo = lngUndo + 1
m_bUndo = True
End If
End If
End If
End If
Set oRng = oTbl.Range
oRng.Collapse wdCollapseEnd
Do While oRng.Characters.Last = vbCr
If oRng.Characters.Last.InRange(oRngEval) Then
If Not oRng.Characters.Last.End = ActiveDocument.Range.End Then
If Not oRng.Characters.Last.Previous.Information(wdWithInTable) Then
oRng.Characters.Last.Delete
lngUndo = lngUndo + 1
m_bUndo = True
Else
'Don't try to delete single paragraphs between tables. Just offset the count by 1.
m_lngOffset = m_lngOffset + 1
Exit Do
End If
Else
Exit Do
End If
Else
Exit Do
End If
Loop
Reenter:
Next oTbl
fcnHandleTables = lngUndo
lbl_Exit:
Exit Function
End Function
Sub CountQualifiedLines()
Dim CharCount As Integer
Dim tCount As Integer
Dim LineCount As Integer
Dim Qualifier As String
Qualifier = InputBox("Enter threshold line length." & vbCr + vbCr _
& "To be counted the line must contain the " _
& "threshold number of characters " _
& "(excluding the line end mark.)", _
"Line Length", 1)
tCount = ActiveDocument.ComputeStatistics(wdStatisticLines)
Selection.HomeKey wdStory
Do While tCount > 0
With Selection
.EndKey Unit:=wdLine, Extend:=wdExtend
CharCount = .Characters.Count
tCount = tCount - 1
On Error GoTo lbl_Exit
If CharCount > Qualifier Then
LineCount = LineCount + 1
End If
.Collapse wdCollapseStart
.MoveDown Unit:=wdLine, Count:=1
.EndKey Unit:=wdLine, Extend:=wdExtend
End With
Loop
Selection.HomeKey wdStory
MsgBox "There are " & LineCount & " qualified lines in this document"
lbl_Exit:
Exit Sub
End Sub
See: Installing Macros for instructions on how to set up and use the macros provided in this Microsoft Word Help & Microsoft Word Tips page.
Bonus Tip: Create your own "Lorem ipsum ..." text in Word 2007/2010 by simply typing =lorem() and pressing enter. What is "Lorem ipsum?" See: Lorem Ipsum. For more dummy text methods see Word MVP Suzanne Barnhill's: Dummy Text
That's it! I hope you have found this Microsoft Word Help & Tips page useful and informative.
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.
If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!