Paste method faile (activesheet.paste)

  • Thread starter Thread starter MS Excel
  • Start date Start date
M

MS Excel

Hi,

While using Activesheet.Paste in a newly created book through workbook.add
function, I got following message
"Paste method of workbook class failed." To my amazement, the same was
working perfectly in MS EXCEL XP
but when upgraded to Excel 2003 its creating problem..

Any idea.?
 
Maybe adding...

msgbox application.cutcopymode

before you do the paste would tell you if there's anything copied that can be
pasted.

If there isn't anything to paste, sometimes just rearranging the order can help.

dim rngtocopy as range
dim newwks as worksheet

with worksheets("sheet99")
set rngtocopy = .range("a1:b99")
end with

set newwks = workbooks.add.worksheets(1)

rngtocopy.copy _
destination:=newwks.range("a1")
 
To my amazement, the same was
working perfectly in MS EXCEL XP
but when upgraded to Excel 2003 its creating problem..

Guess this isn't completely factual.
 
Did the OP post something somewhere else?

I would have guessed that it wasn't just the change of versions that did
this--but it could have been a something that occurred at the same time that may
have killed the cutcopymode?

Maybe an event macro was added that kills it--who knows?
 
I m using selection.copy method...
one more thing... when typing activesheet. i m not getting any drop down
list (online help)
 
Below is the code that i want to run. but.. it fails on last line..

Sub Testing()

Range("A5").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add Template:="Workbook"
Range("B2").Select
Application.CutCopyMode = True
ActiveSheet.Paste

End Sub

MS Excel said:
I m using selection.copy method...
one more thing... when typing activesheet. i m not getting any drop down
list (online help)
 
Try changing the order of your code:

Option Explicit
Sub Testing()

Dim myRng As Range
Dim newWks As Worksheet
Dim CurWks As Worksheet

Set CurWks = ActiveSheet

With CurWks
Set myRng = .Range("a5", .Range("a5").End(xlToRight))
Set myRng = .Range(myRng, myRng.End(xlDown))
End With

Set newWks = Workbooks.Add.Worksheets(1)

myRng.Copy _
Destination:=newWks.Range("b2")

Application.CutCopyMode = False

End Sub



MS said:
Below is the code that i want to run. but.. it fails on last line..

Sub Testing()

Range("A5").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Workbooks.Add Template:="Workbook"
Range("B2").Select
Application.CutCopyMode = True
ActiveSheet.Paste

End Sub
 
If you use a variable for the activesheet (and declare it as a worksheet),
you'll see VBA's intellisense.

dim curwks as worksheet
set curwks = activesheet
with curwks
.....

MS said:
I m using selection.copy method...
one more thing... when typing activesheet. i m not getting any drop down
list (online help)
 
Thanks for your support.
I will check & will revert with outcomes.

Syed
 
Sorry for bothering you again... but now its showing another error, "Copy
mehtod of Range class failed".

however, the data is properly pasted in the next sheet and after that error
appeared.

Thanks for your support.
I will check & will revert with outcomes.

Syed
 
The code I posted worked ok for me and I don't see anything in that code that
would cause trouble.

You may want to post the code you're using.

MS said:
Sorry for bothering you again... but now its showing another error, "Copy
mehtod of Range class failed".

however, the data is properly pasted in the next sheet and after that error
appeared.
 
I tried your code in new workbook created under 2003. its working fine.

Thanks for your support,


Dave Peterson said:
The code I posted worked ok for me and I don't see anything in that code
that
would cause trouble.

You may want to post the code you're using.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top