is the cursor in a heading paragraph?

G

gary

Hi all,

how can I find out if the cursor (selection) is located within a
heading paragraph? my heading-styles do not have generic names
("Heading1", "Heading2", etc.) but are named quite individually.

TIA,
gary
 
P

Peter Hewett

Hi gary

You can use:
Selection.Range.Style

But beware, if you have more than one paragraph selected and they use different styles the
above code will throw and error (91 - Object variable or with block not set). So you may
need to add extra code to handle this condition - it depends on what you want to do when
you encounter this condition.

HTH + Cheers - Peter


(e-mail address removed) (gary), said:
 
K

Klaus Linke

Hi Gary,

Or you could use
If Selection.Paragraphs(1).OutlineLevel <> wdOutlineLevelBodyText then '...
(which also works if the outline level has been applied manually)

Regards,
Klaus
 

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