determining which paragraph style the selection has?

J

JB

Hi Folks,

I have a macro which loops through a document which has predefined paragraph
styles and character styles inside these paragraph styles. I'm looping thru
these char styles and storing the selection but when I get to the end of a
para and try to determine the paragraph style I get an error "object
variable or block with not set".

I know why this is happening (selection moves to next line and paragraphs
have different styles which sets selection.style to nothing) but I don't
know the best way around it! Is there a way I can check for a NULL value in
selection.style so I can then say IF NULL then blah blah blah???


Cheers

JB
 
H

Helmut Weber

Hi,
the following should be sufficient:
On Error Resume Next
MsgBox Selection.Style
On Error GoTo -1 ' resets error to 0
For a more detailed approach you may use err.number.
E.g. if err.number = 91 then

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 

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