#1
|
|||
|
|||
PasteAppendTable not available (Run-Time Error 4605)
I am writing a macro in Word that will copy a large range from an Excel document and paste it into an existing table in the Word document. The macro places the cursor in the table, opens the the specified Excel document, copies the range, and closes the Excel document, leaving the data on the clipboard. As soon as the document closes, Word throws Run-Time Error 4605, "Command not available," on the line where I attempt to paste the range.
Here's the code: Code:
Dim XLApp As Object Dim XLDoc As Object Dim WDApp As Object Dim filepath As String filepath = InputBox("Enter the filepath of the spreadsheet:", "Enter filepath", "C:\") Set XLApp = CreateObject("Excel.Application") Set WDApp = Word.Application XLApp.Visible = True XLApp.Workbooks.Open filepath 'Copy data range (ending cell is an arbitrary large number) XLApp.CutCopyMode = True XLApp.ActiveWorkbook.Worksheets(1).Range("A2:G650").Select XLApp.Selection.Copy XLApp.ActiveWorkbook.Close XLApp.Application.Quit 'Paste the range, merging with the existing table With WDApp Selection.PasteAppendTable '*****Error thrown here End With Code:
Dim MyData As MSForms.DataObject Dim strClip As Variant Set MyData = New MSForms.DataObject MyData.GetFromClipboard strClip = MyData.GetText strClip.PasteAppendTable When I end the code (after the error), "append table" does appear as a special paste option on the Ribbon button. I'm not sure why VBA can't find the command. Any help/advice/insight is greatly appreciated. |
#2
|
|||
|
|||
(Bump) Anyone? Any additional information I can provide? This is the last week I have to work on this problem, so any help would be greatly appreciated.
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
PasteAppendTable Question | danenorman13 | Word VBA | 2 | 05-24-2013 04:55 PM |
Get Run-time Error 11 | Jamtart | PowerPoint | 2 | 08-31-2012 05:04 AM |
Run time error 1004 | yonasan | Excel Programming | 3 | 06-12-2012 11:08 PM |
Word Visual Basic error - run time error 504 | crazymorton | Word | 11 | 01-13-2012 04:32 AM |
Run-time error 438 | cksm4 | Word | 2 | 01-12-2011 03:41 PM |