|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
可试试用Lines等对象遍历行的方法:- Sub test()
- '提取页面各行内容
- Dim i%, J%, k%, n%, d, info
- Dim aPage As Page
- Dim aRec As Rectangle
- Dim aLine As Line
-
- On Error Resume Next
- Set d = CreateObject("Scripting.Dictionary")
- With ActiveDocument.ActiveWindow.Panes(1)
- For Each aPage In .Pages
- i = i + 1
- For Each aRec In aPage.Rectangles
- J = J + 1
- For Each aLine In aRec.Lines
- k = k + 1
- With aLine
- ' .Range.Select
- If .LineType = wdTextLine Then '是文字行(不是表格行)时
- d(n) = Replace(.Range.Text, Chr(13), "┛")
- Else
- d(n) = Replace(.Range.Text, Chr(13), "┛") & "※"
- End If
- End With
- n = n + 1
- Next
- k = 0
- Next
- J = 0
- If i > 3 Then Exit For '仅提取前3页
- Next
- End With
- info = d.Items
- Documents.Add.Content.Text = "(用“┛”表示回车符,表格行后用“※”标记)" & vbCrLf & Join(info, vbCrLf)
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|