0

我试图在 VBA for Word 中的两个内容控件之间划线。我想在两个内容控件之间设置默认换行符。如果它之间有两个以上的换行符,我想删除其他的。

在循环中执行我的代码时,将字符串合并到内容控件中会在合并到内容控件后产生多个换行符。

如何在两个内容控件之间设置默认的两个换行符?

Content control A
- line break
- line break 
Content control B
4

1 回答 1

0

我已经找到了解决方案。

Sub RemoveLineBreak()

Dim rStart As Range
Dim rEnd As Range


    ActiveDocument.SelectContentControlsByTag("ContentC1").Item(1).Range.Select
    Selection.MoveDown Unit:=wdLine, Count:=1

Set rStart = Selection.Range

    ActiveDocument.SelectContentControlsByTag("ContentC2").Item(1).Range.Select
    Selection.MoveUp Unit:=wdLine, Count:=1

Set rEnd = Selection.Range

    ActiveDocument.Range(rStart.Start, rEnd.End).Select
    Selection.Delete
    Selection.InsertBreak Type:=wdLineBreak

End Sub
于 2017-09-30T17:18:24.213 回答