2017-08-26 6 views
1

私は約1000個のテーブルがあり、それぞれにキャプションがあるワードドキュメントがあります。私はこれらのテーブルを100個のグループ(各グループに10個のテーブル)にグループ化し、各グループを新しいワードドキュメント(デスクトップ上に保存した「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 
を始めるためのスニペットです
関連する問題