Code:
Sub CopyTables() Dim oDoc As Document Dim oDocTarget As Document Dim oTbl As Table, oTblTarget As Table Dim oRng As Range Set oDoc = ActiveDocument Set oDocTarget = Documents.Add For Each oTbl In oDoc.Tables Set oRng = oDocTarget.Range With oRng .Collapse wdCollapseEnd oRng.FormattedText = oTbl.Range.FormattedText Set oTblT = oRng.Tables(1) oTblT.Style = "Table Grid" .Collapse wdCollapseEnd .Text = vbCrLf End With Next
'It is called stet: 'oDocTarget.Range.Select 'Selection.ClearFormatting 'Selection.Collapse wdCollapseStart oDoc.Activate lbl_Exit: Exit Sub End Sub
[moderator attempt to reformat - think I got it right - CK ]
Code:
Sub CopyTables()
Dim oDoc As Document
Dim oDocTarget As Document
Dim oTbl As Table, oTblTarget As Table
Dim oRng As Range
Set oDoc = ActiveDocument
Set oDocTarget = Documents.Add
For Each oTbl In oDoc.Tables
Set oRng = oDocTarget.Range
With oRng
.Collapse wdCollapseEnd
.FormattedText = oTbl.Range.FormattedText
Set oTblT = oRng.Tables(1)
oTblT.Style = "Table Grid"
.Collapse wdCollapseEnd
.Text = vbCrLf
End With
Next
'It is called
stet:
'oDocTarget.Range.Select
'Selection.ClearFormatting
'Selection.Collapse wdCollapseStart
oDoc.Activate
lbl_Exit:
Exit Sub
End Sub