
Signature
Alex St-Pierre
For nbTab = 1 To 3
If nbTab = 1 Then
Set rngExcel = wbExcel.Application.sheets("table1.1").Range("table1_1")
Set rng = docWord1.Bookmarks("Table1_1").Range
ElseIf nbTab = 2 Then
Set rngExcel = wbExcel.Application.sheets("table1.2").Range("table1_2")
Set rng = docWord1.Bookmarks("Table1_2").Range
ElseIf nbTab = 3 Then
Set rngExcel = wbExcel.Application.sheets("table1.3").Range("table1_3")
Set rng = docWord1.Bookmarks("Table1_3").Range
End If
Set tbl = rng.Tables(1)
tbl.Delete
rngExcel.Copy
Selection.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
RTF:=True
Set tbl = rng.Tables(1)
...
Next nbTab
Hi, Alex. I'm not an expert by any means, but let me make a suggestion:
Try replacing Selection in
Selection.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
with tbl.Range to give
tbl.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
"Range" returns an area independent of the insertion point / cursor
position. "Selection" returns the exact insertion point, regardless of any
range you have referenced in your code. If your insertion point is in a
table cell, then Selection will paste everything there, and ignore any
referenced range.
HTH
Ed
> Hi,
> I have a table in Word and I replace it by a range table in excel. Excel
[quoted text clipped - 7 lines]
> using delete and copy-paste function ?
> Thanks !
Alex St-Pierre - 09 Apr 2006 20:32 GMT
I tried this but the newtable is always added to the old table
Set tbl = rng.Tables(1)
rngExcel.Copy
tbl.Range.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
RTF:=True
Set tbl = rng.Tables(1)
This works:
Set tbl = rng.Tables(1)
rngExcel.Copy
tbl.select
selection.PasteExcelTable LinkedToExcel:=False, WordFormatting:=False,
RTF:=True
--
Alex St-Pierre
"Ed" a écrit :
> Hi, Alex. I'm not an expert by any means, but let me make a suggestion:
> Try replacing Selection in
[quoted text clipped - 22 lines]
> > using delete and copy-paste function ?
> > Thanks !