TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Microsoft > Microsoft Office

Word count for a particular style?

Microsoft Office

 
 
Thread Tools Display Modes
Unread 28-08-2007, 01:08 PM   #1
Dave Morgan
Guest
 
Posts: n/a
Word count for a particular style?

Greetings, I hope that one of the VBA a wizards can say "Oh that's easy.....

Q; Can I use the ComputeStatistics function to calculate the number of words
in a document that are formated with a particular style or create a breakdown
of words by style? ... and if so, can you please point me in the right
direction of where to find more information.

Kind Regards and thanks for your time.

Dave
 
Unread 28-08-2007, 01:08 PM   #2
Jay Freedman
Guest
 
Posts: n/a
Re: Word count for a particular style?

Hi Dave,

For a single style, or just a few styles, you don't need a macro.
First go to the Tools > Options > Edit dialog and check the box for
"Keep track of formatting". Open the Styles and Formatting task pane.
Click the down arrow next to the style name (or right-click the style
name itself) and choose "Select all x instances". Then click Tools >
Word Count and read off the statistics for that style.

Writing a macro to get a word count for each style isn't quite
trivial, but it wouldn't be very difficult. The general idea is this:
The outer loop is For Each style in ActiveDocument.Styles ... Next.
Within that loop, set a Range object equal to ActiveDocument.Range,
then use that Range object's .Find to search for occurrences of the
current style. Each time it's found, use the Range object's
..ComputeStatistics(wdStatisticWords) method to get the number of words
in that occurrence and add it to a running total for the style. Keep
the results in a N x 2 array where the first column is the style name
and the second column is the final value of the running total for that
style.

If you need more guidance, ask in the
microsoft.public.word.vba.beginners newsgroup
(http://www.microsoft.com/communities...vba.beginners).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 19 Aug 2007 16:00:02 -0700, Dave Morgan
<DaveMorgan@discussions.microsoft.com> wrote:

>Greetings, I hope that one of the VBA a wizards can say "Oh that's easy.....
>
>Q; Can I use the ComputeStatistics function to calculate the number of words
>in a document that are formated with a particular style or create a breakdown
>of words by style? ... and if so, can you please point me in the right
>direction of where to find more information.
>
>Kind Regards and thanks for your time.
>
>Dave

 
Unread 28-08-2007, 01:10 PM   #3
Dave Morgan
Guest
 
Posts: n/a
Re: Word count for a particular style?

Jay, That's fantastic! for now I'll use the manual but quick method. Later
when I have some time I'll visit the vba forum. This will make writing
college assignments so much easier. Just formatting using styles will allow
for adjusting the word count to omit Fig and Table captions etc. So, Job Done!

Thanks again for your time and efforts.

Kind Regards,

Dave Morgan

"Jay Freedman" wrote:

> Hi Dave,
>
> For a single style, or just a few styles, you don't need a macro.
> First go to the Tools > Options > Edit dialog and check the box for
> "Keep track of formatting". Open the Styles and Formatting task pane.
> Click the down arrow next to the style name (or right-click the style
> name itself) and choose "Select all x instances". Then click Tools >
> Word Count and read off the statistics for that style.
>
> Writing a macro to get a word count for each style isn't quite
> trivial, but it wouldn't be very difficult. The general idea is this:
> The outer loop is For Each style in ActiveDocument.Styles ... Next.
> Within that loop, set a Range object equal to ActiveDocument.Range,
> then use that Range object's .Find to search for occurrences of the
> current style. Each time it's found, use the Range object's
> ..ComputeStatistics(wdStatisticWords) method to get the number of words
> in that occurrence and add it to a running total for the style. Keep
> the results in a N x 2 array where the first column is the style name
> and the second column is the final value of the running total for that
> style.
>
> If you need more guidance, ask in the
> microsoft.public.word.vba.beginners newsgroup
> (http://www.microsoft.com/communities...vba.beginners).
>
> --
> Regards,
> Jay Freedman
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
>
> On Sun, 19 Aug 2007 16:00:02 -0700, Dave Morgan
> <DaveMorgan@discussions.microsoft.com> wrote:
>
> >Greetings, I hope that one of the VBA a wizards can say "Oh that's easy.....
> >
> >Q; Can I use the ComputeStatistics function to calculate the number of words
> >in a document that are formated with a particular style or create a breakdown
> >of words by style? ... and if so, can you please point me in the right
> >direction of where to find more information.
> >
> >Kind Regards and thanks for your time.
> >
> >Dave

>

 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
linked style type in Word 2007 Office Productivity Consultant Microsoft Office 10 14-09-2007 03:32 PM
Word 2007 - Automatically Update Style saraj28163 Microsoft Office 1 03-09-2007 08:59 AM
Word should let me exclude identified text from the word count dearjack Microsoft Office 1 28-08-2007 11:16 PM
RE: Significance of style in MS-Word Rathish Microsoft Office 2 28-08-2007 12:56 PM
RE: WORD COUNT Jason Insearching1977 Microsoft Office 2 28-08-2007 08:37 AM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 01:30 PM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional