|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
原代码13行确实有点问题,虽然在新文档输出处理结果没有影响。应改为
If i > 0 Then data(2, i) = data(1, i - 1) Else data(2, i) = .Range.End - 1
以下改为全部用变量docend的值(经修改),可再试试:
- Sub test()
- '基于题目应用了特定的自动编号(阿拉伯数字)
- Dim i%, docend&, data$()
- Dim ListPara As Paragraph
-
- Application.ScreenUpdating = False
- With ActiveDocument
- docend = .Content.End - 1
- For Each ListPara In .ListParagraphs
- If ListPara.Range.ListFormat.ListString Like "#*" Then
- ReDim Preserve data(2, i)
- data(1, i) = ListPara.Range.start
- If i > 0 Then data(2, i) = data(1, i - 1) Else data(2, i) = docend
- data(0, i) = Trim(Replace(ListPara.Range.Text, Chr(9), ""))
- i = i + 1
- End If
- Next
- WordBasic.SortArray data, 0, 0, UBound(data, 2), 1, 0
- For i = 0 To UBound(data, 2)
- .Bookmarks("\endofdoc").Range.FormattedText = .Range(data(1, i), data(2, i))
- Next
- .Range(0, docend).Delete
- End With
-
- Application.ScreenUpdating = True
- MsgBox "共处理了" & UBound(data, 2) + 1 & "道题", vbInformation
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|