Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
Amish Amish is offline
external usenet poster
 
Posts: 35
Default Style Count in Word 2003

Can someone tell me how I can determine how many times a style occurs
a document?

I'm trying to write a macro, but I would like to use the value that
Word displays when I view the style list (it tells me I can select all
12 instances, for example).

Thank you.
  #2   Report Post  
Posted to microsoft.public.word.newusers
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Style Count in Word 2003

Use the following, substituting the style that you want for Heading 1

Dim i As Long
i = 0
Selection.HomeKey wdStory
Selection.Find.Style = "Heading 1"
With Selection.Find
Do While .Execute(FindText:="", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
i = i + 1
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 1
Loop
End With
MsgBox "There are " & i & " instances of the Heading 1 style in the
document."


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
"Amish" wrote in message
...
Can someone tell me how I can determine how many times a style occurs
a document?

I'm trying to write a macro, but I would like to use the value that
Word displays when I view the style list (it tells me I can select all
12 instances, for example).

Thank you.


  #3   Report Post  
Posted to microsoft.public.word.newusers
Amish Amish is offline
external usenet poster
 
Posts: 35
Default Style Count in Word 2003

Thanks Doug.

On Jun 11, 7:14*pm, "Doug Robbins - Word MVP"
wrote:
Use the following, substituting the style that you want for Heading 1

Dim i As Long
i = 0
Selection.HomeKey wdStory
Selection.Find.Style = "Heading 1"
With Selection.Find
* * Do While .Execute(FindText:="", Forward:=True, _
* * * * MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
* * * * i = i + 1
* * * * Selection.Collapse wdCollapseEnd
* * * * Selection.MoveRight wdCharacter, 1
* * Loop
End With
MsgBox "There are " & i & " instances of the Heading 1 style in the
document."

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com"Amish" wrote in message

...

Can someone tell me how I can determine how many times a style occurs
a document?


I'm trying to write a macro, but I would like to use the value that
Word displays when I view the style list (it tells me I can select all
12 instances, for example).


Thank you.


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a field containing the word count of just one style? mlse Microsoft Word Help 2 April 25th 09 05:13 PM
Word count associated to a style AussieBlueDog Microsoft Word Help 14 March 20th 09 01:08 AM
Word count for a particular style? Dave Morgan Microsoft Word Help 3 July 18th 08 09:07 PM
style count appears in header of PDF version sandy Microsoft Word Help 5 May 28th 08 04:44 PM
Count of words in Word 2007 and count in 2003 are different Gabi Microsoft Word Help 2 May 27th 08 12:20 PM


All times are GMT +1. The time now is 02:32 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"