D
DaleH
I have some code that iterates through the paragraphs in the paragraph
collection of the ActiveDocument and sets the LeftIndent for the paragraph
based on the paragraph above it (actually the TextPosition property of a List
item above it).
Everything is fine until I hit a paragraph that is actually embedded in a
table cell instead of being free standing. The result is that the LeftIndent
for the text does get placed where I want it (inside the cell), but the table
that it lives inside is still flush left and I'd like to move it over too.
This is complicated when there are two columns in this table... my code finds
the paragraph in the second column as well and sets its indent relative to
the left edge of the 2nd column, which I don't want to do at all.
So tables and paragraphs intermingle, but the paragraph collection doesn't
seem to know about the tables and the table collection doesn't know about
paragraphs.
Here's a snip of code (see embedded comments):
intOutlineLevel = 0
intTextPositionAbove = 0
For Each para In ActiveDocument.Paragraphs
If Mid(para.Style, 1, 9) = "MM Topic " Then
intOutlineLevel = para.OutlineLevel
intTextPositionAbove = para.LeftIndent
para.Range.ListFormat.ApplyListTemplate _
ListTemplate:=ltTemp, ContinuePreviousList:=True
Else
If (para.Style = "Normal" Or Mid(para.Style, 1, 3) = "MM ") Then
' If this para is in a table, I'd like to indent the table
instead of the paragraph
' If this para is in the second column of a table I don't want
to indent at all!
If (para.LeftIndent - intTextPositionAbove) <= 0 Then
para.LeftIndent = InchesToPoints(0.25 * intOutlineLevel)
Else
para.LeftIndent = InchesToPoints(0.25 * intOutlineLevel) + _
(para.LeftIndent - intTextPositionAbove)
End If
End If
End If
Next para
Thanks in advance for your ideas...
Dale
collection of the ActiveDocument and sets the LeftIndent for the paragraph
based on the paragraph above it (actually the TextPosition property of a List
item above it).
Everything is fine until I hit a paragraph that is actually embedded in a
table cell instead of being free standing. The result is that the LeftIndent
for the text does get placed where I want it (inside the cell), but the table
that it lives inside is still flush left and I'd like to move it over too.
This is complicated when there are two columns in this table... my code finds
the paragraph in the second column as well and sets its indent relative to
the left edge of the 2nd column, which I don't want to do at all.
So tables and paragraphs intermingle, but the paragraph collection doesn't
seem to know about the tables and the table collection doesn't know about
paragraphs.
Here's a snip of code (see embedded comments):
intOutlineLevel = 0
intTextPositionAbove = 0
For Each para In ActiveDocument.Paragraphs
If Mid(para.Style, 1, 9) = "MM Topic " Then
intOutlineLevel = para.OutlineLevel
intTextPositionAbove = para.LeftIndent
para.Range.ListFormat.ApplyListTemplate _
ListTemplate:=ltTemp, ContinuePreviousList:=True
Else
If (para.Style = "Normal" Or Mid(para.Style, 1, 3) = "MM ") Then
' If this para is in a table, I'd like to indent the table
instead of the paragraph
' If this para is in the second column of a table I don't want
to indent at all!
If (para.LeftIndent - intTextPositionAbove) <= 0 Then
para.LeftIndent = InchesToPoints(0.25 * intOutlineLevel)
Else
para.LeftIndent = InchesToPoints(0.25 * intOutlineLevel) + _
(para.LeftIndent - intTextPositionAbove)
End If
End If
End If
Next para
Thanks in advance for your ideas...
Dale