|
楼主 |
发表于 2016-10-8 21:51
|
显示全部楼层
老师帮忙看一下,为什么这个代码实现不了我的需求,好像或 的效果没实现
- Sub shishi()
- Dim mt, oRang As Range, rng As Range, n%, m%
- Dim arr(1 To 10000, 1 To 1)
- Set rng = ActiveDocument.Content
- Dim s1, s2, s3, s4
- s1 = "^[一二三四五六七八九十〇百千万]+、\s*)[^\r]*$"
- s2 = "^(\s*[一二三四五六七八九十〇百千万]+\s*)[^\r]*$"
- s3 = "^[\u2488-\u249B][^\r]*$"
- s4 = "^(\s*\d+\s*)[^\r]*$"
- s = s1 & "|" & s2 & "|" & s3 & "|" & s4
- With CreateObject("vbscript.regexp")
- .Pattern = s1 & "|" & s2 & "|" & s3 & "|" & s4
- .Global = True: .MultiLine = True
- For Each mt In .Execute(rng)
- m = mt.FirstIndex: n = mt.Length
- Set oRang = ActiveDocument.Range(m, m + n)
- 'oRang.Font.Size = 14
- 'oRang.Font.Name = "宋体"
- k = k + 1
- arr(k, 1) = oRang.Text
- Next
- End With
- With CreateObject("Excel.Application")
- If Tasks.Exists("Microsoft Excel") = True Then Tasks("Microsoft Excel").Close
- Set myBook = .Workbooks.Add: .Visible = True
- Set mysheet = myBook.Worksheets("sheet1"): mysheet.Activate
- mysheet.Range("a1").Resize(10000, 1) = arr
- End With
- Set myBook = Nothing
- Set mysheet = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|