Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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
Posted to microsoft.public.word.newusers
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I create a field containing the word count of just one style? | Microsoft Word Help | |||
Word count associated to a style | Microsoft Word Help | |||
Word count for a particular style? | Microsoft Word Help | |||
style count appears in header of PDF version | Microsoft Word Help | |||
Count of words in Word 2007 and count in 2003 are different | Microsoft Word Help |