我正在尝试从项目符号列表中删除当前样式,并在每行的开头和结尾添加文本。到目前为止, InsertBefore 可以工作,但要使用“InsertAfter”,我需要将插入点向左移动一个字母的空格,否则新文本将被添加到下一行的开头(当前换行符的右侧)。
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
答案 0 :(得分:3)
这样的事情可能是:
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