我试图从项目符号列表中删除当前样式,并将文本添加到每行的开头和结尾。到目前为止,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
最佳答案
可能是这样的:
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
关于vba - 在 Word 中每行末尾添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21540789/