Counting words in Word

Posted on 2011-10-30
Last Modified: 2012-11-28
I currently have a field in my document (my college assignment) that shows the word count minus the preamble (cover page and TOC) and the postamble (bibliography etc), it looks like this

Word Count: [ {={NUMWORDS\# "#,##0" } - 63 -132 } ]

Open in new window

i know i could just write -195, but its easy to think in pre and post amble terms.

What i would like to do is to use some kind of variables that i can set in the document properties, i have tried this

{{{ SET "iSizePre" "63" }{ SET "iSizePos" "132" }{={NUMWORDS\# "#,##0" } - { REF "iSizePre" } - {REF "iSizePos" }}}}

Open in new window

But it doesnt display anything, what am i doing wrong?

Oh and i am using Word 2007 SP2
Question by:Gerald Connolly
    LVL 76

    Assisted Solution

    You seem to have doubly nested the result in otherwise empty outer fields. Also, if you want to use the number format switch, format the result, not one of components of the calculation.

    {SET "iSizePre" "63"  }{ SET "iSizePos" "132" }{ ={ NUMWORDS} -  REF "iSizePre" }{  - {REF "iSizePos"  }  \# "#,##0"}

    LVL 16

    Accepted Solution

    i think i had to do it like that as that was the only way i could get rid of the syntax error
    LVL 16

    Author Closing Comment

    by:Gerald Connolly
    Not really a solution

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
    This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
    This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
    This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now