Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to order paragraph styles in an array?

Status
Not open for further replies.

nesplb

Programmer
Jul 29, 2003
109
0
0
NO
Hi all!
I want to loop through the paragraphs in a document and count the occurences of each paragraph style that is in the document. If for instance the style "Normal" has 5 paragraph occcurences it should count all 5.
I guess I have to put each new paragraph i find in some kind of array and then add 1 in a datafield each time I find a new occurence of that paragraph. Is that right?
How is the best way to do this? And how would some code look like? (Im not used to work with arrays in VB)

In advance, thanks:)

Pål Nesteby

PDC-Tangen
Norway
 
I mean offcourse:
"add 1 in a datafield each time I find a new occurence of that paragraph STYLE. "

Pål Nesteby

PDC-Tangen
Norway
 



Pål,

Check out the ReDim Preserve statement for your array. You'll want maybe a two dimensional array.



Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Okey...
How do i use and populize that? I'm sorry im completely new to these arrays....

TY:)

Pål Nesteby

PDC-Tangen
Norway
 

Dim p As Paragraph
Dim pArray [AN ARRAY TO HOLD PARAGRAPH STYLES AND THE NUMBER OF OCCURENCES OF EACH]

For Each p In ActiveDocument.Paragraphs

'if p.style is not in pArray- add it to
'pArray.
'else if p.style is allready in pArray add
'1 to det "count" field for that specific paragraph style
'in pArray.

Next p

Pål Nesteby

PDC-Tangen
Norway
 
I'd use a Collection or a Scripting.Dictionary object instead of an array ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Okay! Thanks, but how do I use it to get what I want? I find no good examples for a newbie on this stuff....



Pål Nesteby

PDC-Tangen
Norway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top