|
* 楼主,我重新构思了一下,改变了思路,具体是:以循环遍历每个表格(及上下各一段)设为区域 r,再将其上和其下的区域全部删除,再另存为,循环处理。请试用:
- Sub test()
- Dim s$, p$, y$, a&, i&, r As Range
- y = ActiveDocument.FullName
- a = ActiveDocument.Tables.Count
- Do While a > 0
- i = i + 1
- If i = 9 Then ActiveDocument.Close savechanges:=wdDoNotSaveChanges: End
- ActiveDocument.Tables(i).Select
- Selection.MoveStart 4, -1
- Selection.MoveEnd 4, 1
- Set r = Selection.Range
- ActiveDocument.Range(Start:=0, End:=r.Start).Select
- If i <> 1 Then Selection.Delete
- ActiveDocument.Range(Start:=r.End, End:=ActiveDocument.Content.End).Select
- If i = a Then
- With r
- .Select
- .Characters.Last.InsertParagraphBefore
- .Characters.Last.InsertParagraphBefore
- End With
- With Selection
- .MoveRight
- .MoveLeft
- .MoveLeft
- .InsertParagraphBefore
- .EndKey 6, 1
- .Delete
- End With
- GoTo en
- End If
- Selection.Delete
- r.Characters.Last.Delete
- en:
- ActiveWindow.ActivePane.View.Zoom.PageFit = wdPageFitFullPage
- With ActiveDocument
- p = .Path & ""
- s = .Tables(1).Range.Cells(3).Range.Text
- s = Left(s, Len(s) - 2)
- .SaveAs FileName:=p & s
- .Close
- End With
- Documents.Open FileName:=y
- Loop
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|