How Many Paragraphs use a Particular Style?

F

Frankbelly

I think Word 2003 handles this better, but I'm using Word 2000 and I'm trying
to figure out how many paragraphs are using a particular style. Is there an
easy way to get a number value for how many paragraphs in the active document
are styled under a certain style name?

Thanks for any help.
 
G

Greg Maxey

Sub ScratchMacro()
Dim oPar As Paragraph
Dim i As Long
For Each oPar In ActiveDocument.Range.Paragraphs
If oPar.Style = "Normal" Then
i = i + 1
End If
Next
MsgBox i
End Sub
 
G

Greg Maxey

Frankbelly,

You are welcome and thank you for your comments.

Fact is, I don't know VBA really well. If you read these newsgroups
you will see that I ask almost as much as I answer and I learn
something new almost everyday.

I don't know much about poetry, but I do enjoy this stuff ;-)
Beautiful! Thank you so much!

I know these things seem so simple to people who know VBA really well, but
for a novice like me, simple direct coding with the least amount of comands
to achieve the results reads like poetry. It's the classic "say more with
less" which takes a lot experience and thought [much like well written
poetry]. Either that or I should get a life. lol :D

Thanks again Greg

Greg Maxey said:
Sub ScratchMacro()
Dim oPar As Paragraph
Dim i As Long
For Each oPar In ActiveDocument.Range.Paragraphs
If oPar.Style = "Normal" Then
i = i + 1
End If
Next
MsgBox i
End Sub

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top