Totally confused as to why the following code is not working.
I’ve a word document with seven tables in it. 1,3 and 5 contains detailed info. 2, 4 and 6 are summaries of those tables. Table seven combines 2,4 and 6 which I copy to a spreadsheet.
Sub CopyTablesForExcelSheet()
ActiveDocument.Tables(7).Delete
Selection.EndKey Unit:=wdStory
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns _
:=5, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed
ActiveDocument.Tables(2).Select
Selection.Copy
ActiveDocument.Tables(7).Rows(1).Cells(1).Range.PasteAsNestedTable
ActiveDocument.Tables(4).Select
Selection.Copy
ActiveDocument.Tables(7).Rows(1).Cells(3).Range.PasteAsNestedTable
ActiveDocument.Tables(6).Select
Selection.Copy
ActiveDocument.Tables(7).Rows(1).Cells(5).Range.PasteAsNestedTable
ActiveDocument.Tables(7).Select
Selection.Copy
End Sub
The code starts off by deleting table 7 and setting it up again. This works fine.
The code then copies and pastes table 2. It will copy table 4, but won’t paste it. I get error 4605 – this command is not available. When I go to debug, the second paste command is highlighted.
The code is OK because I’ve changed the order and the first paste always works. Sometimes the second paste works, then the third one doesn’t.
Why is this happening?