H
hgoslin
Hi
I would appreciate some help in coding a macro that finds each instance
of a caption style in a document and sets the caption to the same left
indent value as its preceding paragraph.
My Caption style is called ARTableCaption
My 3 possible paragraph styles which preceed each caption are:
ARBodyText Level1 Left Indent 1 cm
ARBodyText Level2 Left Indent 2 cm
ARBodyText Level3 Left Indent 3.25 cm
This is my code so far, but it is not working.
With ActiveDocument.Content.Find
.Style = "ARTableCaption"
Do While .Execute(FindText:="", Forward:=True, _
Format:=True) = True
Selection.MoveUp Unit:=wdLine, Count:=1
If Selection.Style = ActiveDocument.Styles("ARBodyText Level1")
Then
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdParagraph, Count:=1,
Extend:=wdExtend
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(1)
.RightIndent = CentimetersToPoints(0)
End With
End If
End With
....
Loop
Thanks
Heather
I would appreciate some help in coding a macro that finds each instance
of a caption style in a document and sets the caption to the same left
indent value as its preceding paragraph.
My Caption style is called ARTableCaption
My 3 possible paragraph styles which preceed each caption are:
ARBodyText Level1 Left Indent 1 cm
ARBodyText Level2 Left Indent 2 cm
ARBodyText Level3 Left Indent 3.25 cm
This is my code so far, but it is not working.
With ActiveDocument.Content.Find
.Style = "ARTableCaption"
Do While .Execute(FindText:="", Forward:=True, _
Format:=True) = True
Selection.MoveUp Unit:=wdLine, Count:=1
If Selection.Style = ActiveDocument.Styles("ARBodyText Level1")
Then
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdParagraph, Count:=1,
Extend:=wdExtend
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(1)
.RightIndent = CentimetersToPoints(0)
End With
End If
End With
....
Loop
Thanks
Heather