|
可试试如下代码,其中每行小题数需指定,且对段落只拆分不合并。
Sub MultiTopic()
Dim myRange As Range, tabcount As Byte, tabwidth As Single, i As Byte
Application.ScreenUpdating = False
With Selection
Set myRange = IIf(.Type = wdSelectionIP, ActiveDocument.Content, .Range)
tabcount = Val(InputBox("请输入每个段落的小题数", , "4"))
If tabcount < 1 Then Exit Sub
tabwidth = myRange.PageSetup.TextColumns.Width / tabcount '计算每个自定义制表位的间距
For i = 1 To tabcount '依次设置每个自定义制表位
myRange.ParagraphFormat.TabStops.Add i * tabwidth
Next
myRange.Select
With .Find
.ClearFormatting
.Text = "^95{3,}" '查找内容(三个以上连续的下划线符号)
.MatchWildcards = True
i = 0 '计数复位
Do While .Execute '对匹配项目循环处理
With .Parent
If .End > myRange.End Then Exit Do '匹配内容如超出指定范围则退出循环
.Text = vbTab '将匹配内容替换为制表符
.Font.Underline = wdUnderlineSingle '匹配内容应用下划线格式
i = i + 1
If i Mod tabcount = 0 And .End < .Paragraphs(1).Range.End - 1 Then .InsertAfter Chr(13) '按指定制表符数拆分段落
.Collapse wdCollapseEnd '向后折叠匹配内容
End With
Loop
End With
End With
Application.ScreenUpdating = True
End Sub
[ 本帖最后由 sylun 于 2009-5-10 17:57 编辑 ] |
评分
-
1
查看全部评分
-
|