PDA

View Full Version : ForcePasteSpecial: getting an error...



emm
10-28-2007, 05:38 PM
I picked up this link srom Mr Excel and and having problems http://www.vbaexpress.com/kb/getarticle.php?kb_id=957 (http://www.vbaexpress.com/kb/getarticle.php?kb_id=957).

I get the following error when I try to undo after one paste:

Error Number 1004: Application-defined or object-defined error.

I noticed there are some PrivateSubs, I put them in the stand module.

XLGibbs
10-28-2007, 05:41 PM
THat is very particular in it's demonstrative purposes. I would presume you tried out the sample file provided and followed the instructions.

For it to work, you need to paste the code in the proper ThisWorkbook event modules.

emm
10-28-2007, 05:57 PM
Went back and opened the example and pasted in my workbook.

In that workbook I tested on a sheet without charts and it worked several times, I pasted the formatting was left off and then I did an undo with no problems.

Then I did the same drill on the sheet with charts and got the error and more importantly when I clicked OK it deleted all the data on the entire sheet.

I can exit without saving and the data is there on the re-open...

XLGibbs
10-28-2007, 06:04 PM
Went back and opened the example and pasted in my workbook.

In that workbook I tested on a sheet without charts and it worked several times, I pasted the formatting was left off and then I did an undo with no problems.



Okay, so we know the code works.



Then I did the same drill on the sheet with charts and got the error and more importantly when I clicked OK it deleted all the data on the entire sheet.


Assume this is in your file not the sample file provided? I would have to test this to duplicate and diagnose, but i don't have too much time left tonight.



I can exit without saving and the data is there on the re-open...

Of course, if you don't save changes, the last saved copy is still there.

ALWAYS work on a backup or extra copy of a file to make sure you don't lose data.

So is the issue that the code as advertised doesn't work as you need it? Or is that you are having trouble assimilating it into your workbook?

Maybe, if there is something specific you need for your workbook, some of us around here can look at the code you are using and offer potential alternatives or edits.

emm
10-28-2007, 06:14 PM
Or is that you are having trouble assimilating it into your workbook?

I believe the code is working just have some bug with this workbook.

I don't have any other code in this book other than the ForcePasteSpecial code.

I could paste the code on Monday or I code post the workbook. I'll try to do some studing of the site to see if that's possible.

Forgot, thanks a bunch for your help--more tomorrow got to get to bed now...