Vba 将word表格复制到新的word文档中
我有一个word文档,其中包含大约1000个表,每个表都有标题。我希望将这些表分成100个组(即每组10个表),然后将每个组保存在一个新的word文档(“newdoc.docx”,我已将其保存在桌面上)。word中是否有任何VBA代码或宏可以帮助我执行此操作 以下是一个片段,让您开始学习Vba 将word表格复制到新的word文档中,vba,ms-office,ms-word,Vba,Ms Office,Ms Word,我有一个word文档,其中包含大约1000个表,每个表都有标题。我希望将这些表分成100个组(即每组10个表),然后将每个组保存在一个新的word文档(“newdoc.docx”,我已将其保存在桌面上)。word中是否有任何VBA代码或宏可以帮助我执行此操作 以下是一个片段,让您开始学习 Sub copyTable() ' one table is already in document Dim srcDoc As Document Set srcDoc = Acti
Sub copyTable()
' one table is already in document
Dim srcDoc As Document
Set srcDoc = ActiveDocument
Dim destDoc As Document
Set destDoc = ActiveDocument ' same doc in this example
Dim tabl As Table
Set tabl = srcDoc.Tables(1)
Dim rng As Range
Set rng = destDoc.Range ' whole doc
rng.Collapse wdCollapseEnd ' collapse range into an insert point at end of doc
tabl.Range.Copy ' source table
' ( could not figure out how to copy directly without copy/paste )
rng.Paste ' paste at insert point
End Sub
下面是一个片段,让您开始学习
Sub copyTable()
' one table is already in document
Dim srcDoc As Document
Set srcDoc = ActiveDocument
Dim destDoc As Document
Set destDoc = ActiveDocument ' same doc in this example
Dim tabl As Table
Set tabl = srcDoc.Tables(1)
Dim rng As Range
Set rng = destDoc.Range ' whole doc
rng.Collapse wdCollapseEnd ' collapse range into an insert point at end of doc
tabl.Range.Copy ' source table
' ( could not figure out how to copy directly without copy/paste )
rng.Paste ' paste at insert point
End Sub