silvkhan
10-10-2012, 06:59 AM
Why ,after Copy and Paste a formatted table text which is the content of a cell, is this table nested inside another table in the new doc?
I copy, with the code below shown, the contents of a table cell and paste it into a new word doc.
I get two different results:
1) if the cell's text has no table, the copy and paste gives a new content not nested inside a table
as it must be correctly
2) if the cell's text has a table, the copy and paste gives a new content which reproduce correctly the cell's content: that table together with other
text, but places all this content inside a new table, I get two nested tables.
Dim oDoc1 As Word.Application
Dim doc2 As Word.Document
Set doc2 = oDoc1.Documents.Add
With oDoc1.ActiveDocument
Set cella = .Range(Start:=.Tables(2).Cell(k, 3).Range.Start, _
End:=.Tables(2).Cell(k, 3).Range.End)
End With
cella.Select
oDoc1.Selection.Copy
doc2.Range.PasteAndFormat (wdPasteDefault)
I copy, with the code below shown, the contents of a table cell and paste it into a new word doc.
I get two different results:
1) if the cell's text has no table, the copy and paste gives a new content not nested inside a table
as it must be correctly
2) if the cell's text has a table, the copy and paste gives a new content which reproduce correctly the cell's content: that table together with other
text, but places all this content inside a new table, I get two nested tables.
Dim oDoc1 As Word.Application
Dim doc2 As Word.Document
Set doc2 = oDoc1.Documents.Add
With oDoc1.ActiveDocument
Set cella = .Range(Start:=.Tables(2).Cell(k, 3).Range.Start, _
End:=.Tables(2).Cell(k, 3).Range.End)
End With
cella.Select
oDoc1.Selection.Copy
doc2.Range.PasteAndFormat (wdPasteDefault)