Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-15-2016, 09:03 AM
dan88 dan88 is offline Paste Table From XL - Word Error -  Bad Parameter Windows 10 Paste Table From XL - Word Error -  Bad Parameter Office 2016
Novice
Paste Table From XL - Word Error -  Bad Parameter
 
Join Date: Feb 2016
Posts: 24
dan88 is on a distinguished road
Default Paste Table From XL - Word Error - Bad Parameter

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
This has me stumped, I am not sure what the problem is

Many thanks for any advice


dan
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste Table From XL - Word Error -  Bad Parameter How can I paste text that's not formatted as a table into a new table? WaltR Word 2 10-11-2014 03:16 PM
Paste Table From XL - Word Error -  Bad Parameter How to paste the data from one table into the cells of another table, without overwriting anything CClio333 Word Tables 1 08-12-2014 05:17 PM
Paste Table From XL - Word Error -  Bad Parameter Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? Joey Cheung Word Tables 1 08-12-2014 05:15 PM
Paste Table From XL - Word Error -  Bad Parameter Can pass .expression as a parameter? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 04:02 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft