I have a table that i'm trying to use as a template that I can then copy to a new page.

i only got this much

Dim oWord As word.Application
        Dim oDoc As word.Document
        Dim oTable As word.Table

        FileCopy("C:/1535.doc", "C:/1535_1" & ".doc")

        oWord = New word.Application
        oDoc = oWord.Documents.Open("C:/1535_1" & ".doc")


        oTable = oDoc.Tables(1)
        oWord.Selection.GoTo(word.WdGoToItem.wdGoToLine, word.WdGoToDirection.wdGoToLast, Nothing, Nothing)


So i want to get a copy of oTable then after the page break it makes a new page but i don't know how go to that page and put a copy of oTable.

Re: copy a word table and paste it in a new page 80 80

I ended making it work heres the code just in case anyone wants it in the future

Dim oWord As word.Application
        Dim oDoc As word.Document
        Dim oTable As word.Table

oTable = oDoc.Tables(1) ' 
oWord.Selection.Tables(1).Select() 'selects your table(template)
oWord.Selection.Copy() 'makes a copy of your template

do while start<end ' your loop to add as many tables you want
       'Your code to edit your table

         'after edit table
           oWord.Selection.Tables(1).Select() ' Selects the table 
           oWord.Selection.MoveDown(word.WdUnits.wdLine, 1)'moves after the table

           oWord.Selection.InsertBreak(word.WdBreakType.wdPageBreak) 'inserts new page
           oWord.Selection.PasteAndFormat(word.WdRecoveryType.wdPasteDefault) 'pastes the original table(template)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.