P
Patrick
I've got a macro written that should be finding all of the
lists of a given style and changing the margin for them.
I've tried doing it about 3 different ways, and get some
interesting problems.
If I try it like this:
---snippet---
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute
Selection.Find.ClearFormatting
With ListGalleries
(wdOutlineNumberGallery).ListTemplates(2).ListLevels(3)
.NumberFormat = "%2."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleLowercaseLetter
.NumberPosition = InchesToPoints(0.75)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1)
.TabPosition = InchesToPoints(1)
.ResetOnHigher = 2
.StartAt = 1
.LinkedStyle = "List Ordered-Lower Case"
End With
Selection.Range.ListFormat.ApplyListTemplate
ListTemplate:=ListGalleries( _
wdOutlineNumberGallery).ListTemplates(2),
ContinuePreviousList:=False, _
ApplyTo:=wdListApplyToWholeList
--- end snippet ---
it changes the for the lists surrounding the lists I need
to reformat.
If I try it like:
--- snippet ---
On Error Resume Next
Dim snt As Word.Range
Dim retval As String
On Error Resume Next
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute
Selection.Find.ClearFormatting
With ActiveDocument.Content.Find
.ClearFormatting
.Style = "List Ordered-Lower Case"
Do While .Execute(findText:="", Forward:=True,
Format:=True) = True _
And Selection.Range.End <>
ActiveDocument.Content.End
With .Parent
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Paragraphs(1).Range.Select
.Move Unit:=wdParagraph, Count:=1
End With
For Each snt In Selection.Sentences
If snt.Style = "List Ordered-Lower Case"
Then
Selection.Range.ListFormat.ListIndent
End If
Next snt
Loop
End With
--- end snippet ---
it works except that it won't indent the first line of my
lists.
So can someone tell me what's wrong with my code? I've
been banging my head on this wall for about a day and a
half now.
lists of a given style and changing the margin for them.
I've tried doing it about 3 different ways, and get some
interesting problems.
If I try it like this:
---snippet---
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute
Selection.Find.ClearFormatting
With ListGalleries
(wdOutlineNumberGallery).ListTemplates(2).ListLevels(3)
.NumberFormat = "%2."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleLowercaseLetter
.NumberPosition = InchesToPoints(0.75)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(1)
.TabPosition = InchesToPoints(1)
.ResetOnHigher = 2
.StartAt = 1
.LinkedStyle = "List Ordered-Lower Case"
End With
Selection.Range.ListFormat.ApplyListTemplate
ListTemplate:=ListGalleries( _
wdOutlineNumberGallery).ListTemplates(2),
ContinuePreviousList:=False, _
ApplyTo:=wdListApplyToWholeList
--- end snippet ---
it changes the for the lists surrounding the lists I need
to reformat.
If I try it like:
--- snippet ---
On Error Resume Next
Dim snt As Word.Range
Dim retval As String
On Error Resume Next
Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute
Selection.Find.ClearFormatting
With ActiveDocument.Content.Find
.ClearFormatting
.Style = "List Ordered-Lower Case"
Do While .Execute(findText:="", Forward:=True,
Format:=True) = True _
And Selection.Range.End <>
ActiveDocument.Content.End
With .Parent
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Paragraphs(1).Range.Select
.Move Unit:=wdParagraph, Count:=1
End With
For Each snt In Selection.Sentences
If snt.Style = "List Ordered-Lower Case"
Then
Selection.Range.ListFormat.ListIndent
End If
Next snt
Loop
End With
--- end snippet ---
it works except that it won't indent the first line of my
lists.
So can someone tell me what's wrong with my code? I've
been banging my head on this wall for about a day and a
half now.