以下是引用apollo086在2005-4-30 8:10:00的发言:
请出手支持
请参考:
'* +++++++++++++++++++++++++++++
'* Created By I Love You_Word!@ExcelHome 2005-4-30 10:40:36
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Option Explicit
Sub CopyTablesToNewDoc()
Dim rngDoc As Range, aTable As Table, shaDoc As Range, aShape As Shape
On Error Resume Next '忽略错误
Application.ScreenUpdating = False '关闭屏幕更新
With ThisDocument '本文档
If .Tables.Count >= 1 Then '表格总数大于1
'定义一个新文档的起始区域
Set rngDoc = Documents.Add.Range(0, 0)
For Each aTable In .Tables
aTable.Range.Copy '复制表格对象
aTable.Delete '删除表格
With rngDoc
.Paste '粘贴
.Collapse Direction:=wdCollapseEnd '折叠到末尾
.InsertParagraphAfter '插入一个空白段落
.Collapse Direction:=wdCollapseEnd '再折叠到末尾
End With
Next
rngDoc.Document.SaveAs "OnlyTables" '另存为
End If
If .Shapes.Count >= 1 Then '如果图形数大于1
Set shaDoc = Documents.Add.Range(0, 0)
For Each aShape In .Shapes '在图形中循环
aShape.Select '选中该图形
Selection.Copy '复制
aShape.Delete '删除
shaDoc.Paste '粘贴
Next
shaDoc.Document.SaveAs "OnlyShapes"
End If
.SaveAs "OnlyText"
End With
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
'----------------------
注意此代码中没有包括使用嵌入式图形,请自行设置代码 |