ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unknown where is the problem on the Runtime error - Automation error (https://www.excelbanter.com/excel-programming/271252-unknown-where-problem-runtime-error-automation-error.html)

wellie

Unknown where is the problem on the Runtime error - Automation error
 
I ran the following code and kept on getting the following
error message after successfully pasting the data
into 'ThisWorkbook.Sheets("BU").Range("A6")'
" Runtime error '-2147417848 (80010108)
Automation error.
The object invoked has disconnected from its clients."

Hence, I'm not able to perform the 2nd copy. I looked
into the MS Support site and it(813120) talked about this
same error but it relates to inserting a pagebreak.
Below is the code. Can someone please tell me where is
the problem ?

Set wkbk = Workbooks.Open(fPathname)
wkbk.Sheets(1).Range("A10:C19").Copy
wkbk.Sheets(1).Paste Destination:=ThisWorkbook.Sheets
("BU").Range("A6")

wkbk.Sheets(1).Range("F10:C19").Copy
wkbk.Sheets(1).Paste Destination:=ThisWorkbook.Sheets
("BU").Range("E6")

Application.DisplayAlerts = False
wkbk.Close fPathname
Application.DisplayAlerts = True


Patrick Molloy[_3_]

Unknown where is the problem on the Runtime error - Automation error
 
Set wkbk = Workbooks.Open(fPathname)
wkbk.Sheets(1).Range("A10:C19").Copy
ThisWorkbook.Sheets("BU").Range("A6").PasteSpecial _
xlallvalues
wkbk.Sheets(1).Range("F10:C19").Copy
ThisWorkbook.Sheets("BU").Range("E6").PasteSpecial _
xlAllValues
wkbk.Close False


Your paste looked odd...the code above should sort you
out.

Patrick Molloy
Microsoft Excel MVP



-----Original Message-----
I ran the following code and kept on getting the

following
error message after successfully pasting the data
into 'ThisWorkbook.Sheets("BU").Range("A6")'
" Runtime error '-2147417848 (80010108)
Automation error.
The object invoked has disconnected from its

clients."

Hence, I'm not able to perform the 2nd copy. I looked
into the MS Support site and it(813120) talked about

this
same error but it relates to inserting a pagebreak.
Below is the code. Can someone please tell me where is
the problem ?

Set wkbk = Workbooks.Open(fPathname)
wkbk.Sheets(1).Range("A10:C19").Copy
wkbk.Sheets(1).Paste Destination:=ThisWorkbook.Sheets
("BU").Range("A6")

wkbk.Sheets(1).Range("F10:C19").Copy
wkbk.Sheets(1).Paste Destination:=ThisWorkbook.Sheets
("BU").Range("E6")

Application.DisplayAlerts = False
wkbk.Close fPathname
Application.DisplayAlerts = True

.



All times are GMT +1. The time now is 03:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com