![]() |
#1
|
|||
|
|||
![]()
Hi folks,
I am copying tables from excel using Paul's code below. I modified it to use excel ranges that feed into each array. The only issue I have now is it pastes the first table from excel into the first bookmark. Then i get error - bad parameter on line .MoveEnd wdTable, 1 https://www.msofficeforums.com/word-...cel-table.html http://www.vbaexpress.com/forum/show...Tables-To-Word Code:
Sub XLTablesWord() Dim i As Long Dim TableArray() As Variant TableArray = Range("TableNames") Dim BookmarkArray() As Variant BookmarkArray = Range("BookmarkNames") '---------PASTE TO DOCUMENT With GetObject("C:\Users\Dan\Desktop\Tables.docx") .Parent.Visible = True For i = LBound(TableArray) To UBound(TableArray) For Each sh In Sheets For Each lob In sh.ListObjects If TableArray(i, 1) = lob.Name Then lob.Range.Copy 'Copy Table Range from Excel With .Bookmarks(BookmarkArray(i, 1)).Range 'Paste Table into MS Word & format .PasteExcelTable LinkedToExcel:=False, WordFormatting:=False, RTF:=False .MoveEnd wdTable, 1 .Tables(1).AutoFitBehavior (wdAutoFitWindow) End With End If Next lob Next sh Next i End With End Sub ![]() Many thanks for any advice dan |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
WaltR | Word | 2 | 10-11-2014 03:16 PM |
![]() |
CClio333 | Word Tables | 1 | 08-12-2014 05:17 PM |
![]() |
Joey Cheung | Word Tables | 1 | 08-12-2014 05:15 PM |
![]() |
tinfanide | PowerPoint | 4 | 12-28-2012 06:14 PM |
Word 2003 Table of Contents Error Message | ktcolburn | Word | 1 | 10-30-2005 06:14 PM |