Question

I am trying to remove the current style from bullets lists and adding text to both the beginning and the end of each line. So far, the InsertBefore works, but to use the "InsertAfter", I need to move the insert point to the left for one-letter space, otherwise the new text will be added to the beginning of the next line (to the right of the current line break mark).

Dim oPara As Word.Paragraph
With seletion
    For Each oPara In ActiveDocument.Paragraphs
        If oPara.Range.ListFormat.ListType = WdListType.wdListBullet Then
            oPara.Range.Select
            oPara.Range.Style = ActiveDocument.Styles(wdStyleNormal)
            oPara.Range.InsertBefore " * "
            oPara2.Range = .Range(oPara.Range.Start, oPara.Range.End - 1)
            oPara2.Range.InsertAfter "&&&"
        End If
    Next
End With
Was it helpful?

Solution

Something like this maybe:

Dim oPara As Word.Paragraph
Dim rng As Range
For Each oPara In ActiveDocument.Paragraphs 'or Selection.Paragraphs
     Set rng = oPara.Range
     With rng
        If .ListFormat.ListType = WdListType.wdListBullet Then
           .Style = ActiveDocument.Styles(wdStyleNormal)
           .InsertBefore " * "
           .Collapse wdCollapseEnd
           .Move wdCharacter, -1
           .InsertAfter "&&&"
        End If
     End With
 Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top