Thanks to the help I received here and, in a separate thread, from Gordon
Bentley-Mix, I have now solved this issue better than I expected. Summary
and code below for those interested.
1) Bookmarks identifying the parts of the document that I do not need to count
2) A macro that counts up
(a) the entire document, including footnotes and endnotes),
(b) the parts I do not need to count, and
(c) notes the normal Word Count (excluding footnotes and endnotes) as of
the time the calculations were made.
3) Document fields codes that
(a) display the relevant information and
(b) include a macrobutton to run the macro. The Macrobutton even changes
labels from "Current" to "Update" depending on whether the displayed
information is current. (You do have to update the macrobutton manually, or
set it to update when printing, or you'll never see the "Update" warning.)
1) Bookmarks: ExcludedBeginning and ExcludedEnding
2) Macro:
Sub xxWordCount()
'
' xxWordCount Macro
' Note relationship b/t temp & doc variables, formally defined later
' ActiveDocument.Variables("xxWordCountAll").Value = a
' ActiveDocument.Variables("xxWordCountNoFN").Value = b
' ActiveDocument.Variables("xxWordCountExBeg").Value = c
' ActiveDocument.Variables("xxWordCountExEnd").Value = d
' ActiveDocument.Variables("xxWordCountExcl").Value = e
' ActiveDocument.Variables("xxWordCountable").Value = f
Dim a As Long
Dim b As Long
Dim c As Long
Dim d As Long
Dim e As Long
Dim f As Long
a = ActiveDocument.ComputeStatistics(Statistic:=wdStatisticWords,
IncludeFootnotesAndEndnotes:=True)
b = ActiveDocument.ComputeStatistics(Statistic:=wdStatisticWords,
IncludeFootnotesAndEndnotes:=False)
' Compute words used in excluded sections of brief
' Beginning sections
Dim ExBegRng As Word.Range
Set ExBegRng = ActiveDocument.Bookmarks("ExcludedBeginning").Range
c = ExBegRng.ComputeStatistics(Statistic:=wdStatisticWords)
' Ending sections
Dim ExEndRng As Word.Range
Set ExEndRng = ActiveDocument.Bookmarks("ExcludedEnding").Range
d = ExEndRng.ComputeStatistics(Statistic:=wdStatisticWords)
' All excluded sections
e = c + d
' Total Countable Words
f = a - e
ActiveDocument.Variables("xxWordCountAll").Value = a
ActiveDocument.Variables("xxWordCountNoFN").Value = b
ActiveDocument.Variables("xxWordCountExBeg").Value = c
ActiveDocument.Variables("xxWordCountExEnd").Value = d
ActiveDocument.Variables("xxWordCountExcl").Value = e
ActiveDocument.Variables("xxWordCountable").Value = f
ActiveDocument.Fields.Update
End Sub
3) Document text with field codes
This document contains {NUMWORDS \# "#,##0" } words per Microsoft Word’s
word count function and {DOCVARIABLE xxWordCountable \# "#,##0"} words ({
DOCVARIABLE xxWordCountAll \# "#,##0" } total - { DOCVARIABLE
xxWordCountExcl \# "#,##0" } excluded) { MACROBUTTON xxWordCount { IF
DocVariable xxWordCountNoFN } = {DOCPROPERTY Words "Current" "Update" } }
per our new word count macro.
The final product says:
This document contains 3,556 words per Microsoft Word’s word count function
and 3,703 words (4,037 total - 334 excluded) (Current) per our new word count
macro.
If I add one word (in a non-counted section), then print or otherwise update
without running the macro, it says:
This document contains 3,557 words per Microsoft Word’s word count function
and 3,703 words (4,037 total - 334 excluded) (Update) per our new word count
macro.