• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 682
  • Last Modified:

Determine the FULL paragraph style in Word

Hi experts,

I'm using a VBA macro to collect information on the paragraph style.  It uses a line like this:

Dim para as paragraph
Dim strStyle as string
Dim arrStyles() as string
Dim i as long

i = 0
For each para in activedocument.paragraphs
  i = i + 1
  arrStyles(i) = para.style
next para

That works fine.  However, it records the short version of the paragraph style, for instance:
If the first paragraph is "Header 1" it records "Header 1" in my array.  Good.
But if the first paragraph is "Header 1 + 10pt" it records "Header 1" in my array. Bad.
It always records the short version and never the full one that takes account of user changes.

So my question for all you experts, Is there any way to capture the full name of the style that is actually used as a string.  In other words, how can I get it to say "Header 1 + 10pt" if that is what the style has become?

Thanks in advance for any advice you can offer.

Cheers,

PatternNut
0
PatternNut
Asked:
PatternNut
  • 2
  • 2
1 Solution
 
GrahamSkanCommented:
Use the description property

arrStyles(i) = para.Style.Description
0
 
PatternNutAuthor Commented:
Hi Graham, it has been a while!  I learned so much from all of your tips that I have had very few queries!

However, I'm afraid this one doesn't seem to solve it.  Or maybe it just needs a little more info.  For the same paragraph, the commands return the following:

Para.style = "Heading 2"

Para.style.description = "Normal + Font: Bold, Indent: Left: 0 Cm Hanging: 1.02cm, tabs: 1.02cm, list tab (etc - it goes on for ages)

And the box in word says: Heading 2 + 11pt

Any ideas?

Thanks,

PatternNut
0
 
GrahamSkanCommented:
The problem is that those the details list character formatting where it differs from the character formatting already associated with the paragraph style.

There can be several of these which can apply to all or part of the paragraph.

I don't think that any of the style properties returns the list, so we may have to analyse the paragraph a character at a time.
0
 
PatternNutAuthor Commented:
Hi Graham,

I don't think that's quite right... I think description is the formatting of the style... and para.style.description therefore doesn't change when the box says Heading 2 + 11pt. or Heading 2 + Not bold, etc.

But I'm awarding the points anyway because this was a very helpful answer and I really appreciate how much thought you put into this.

Thank ye sir,

PatternNut
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now