2017-08-26 106 views
1

我有一個單詞文檔,其中包含大約1000個表格,每個表格都帶有其標題。我希望將這些表分組爲100個組(即每個組中有10個表),然後將每個組保存在一個新的word文檔中(我保存在桌面上的「newdoc.docx」)。有沒有可以幫助我做到這一點的任何VBA代碼或宏中的宏?將單詞表複製到一個新的單詞文檔中

回答

0

這裏是一個片段,讓你開始

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 
相關問題