Paragraphs and LeftIndent

M

Mika

Hi,

I have a Word docuent with the following paragraphs:

a a a a a a a a a a a a a a a a a
a a a a a a a a a a a a a a a a a

b b b b b b b b b b b b b b b b b
b b b b b b b b b b b b b b b b b

c c c c c c c c c c c c c c c c c c c

d d d d d d d d d d d d d d d d d
d d d d d d d d d d d d d d d d d

In other words, the 1st, 2nd, and 4th paragraphs are left indented.

For k = 1 To ActiveDocument.Paragraphs.Count
Set para = ActiveDocument.Paragraphs(k).Range

MsgBox para.ParagraphFormat.LeftIndent
Next k

When using this code, only the 2nd pararaph will get the value which is
bigger that zero. Why is that so? I have to know which paragraphs are
left indented - how can I do that?

Mika
 
P

Peter Hewett

Hi Mika

The code you've posted should work, but I'd do it this way:

Public Sub IndentedParas()
Dim pghItem As Word.Paragraph

For Each pghItem In ActiveDocument.Paragraphs
If pghItem.LeftIndent <> 0 Then
' This paragraph is left indented either positively or negatively
End If
Next
End Sub

Trying to index the Paragraph number of large documents can be phenomenally slow.

HTH + Cheers - Peter
 
C

Charles Kenyon

I just ran the following in Word 2003 and it produced results:

Sub IsIndented()
Dim k As Integer
Dim para As Range

For k = 1 To ActiveDocument.Paragraphs.Count
Set para = ActiveDocument.Paragraphs(k).Range

MsgBox para.ParagraphFormat.LeftIndent
Next k

End Sub

Have you checked the actual indent settings on your other paragraphs?
(Shift-F1 and click on a paragraph.) I generated my document text using
=Rand(7,7) and then indented one paragraph manually on the ruler.
 
K

Klaus Linke

Hi Mika,

To add other possibilities:
A "first line" indent might look the same as a left indent for single-line
paragraphs.
Also, some paragraphs may get their indent through "bullets and numbering",
even though no bullet or number is visible.

You might use Shift+F1 (Reveal formatting) to look for the cause of the
indents.

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