Run-time error '1004': Pate method of worksheet class failed

ExcelRooky91

New Member
Joined
Apr 3, 2018
Messages
10
Hi guys,

I'm scratching my head a little bit with this error. The VBA code I have, which pastes a screenshot, is as below. What I'm finding is that it is very temperamental. Some days the code works fine. Other days it comes up with the error as shown in the title. After pasting the screenshot, the next Sub saves and closes the workbook. However, if an error occurs, this ofcourse does not happen.

Is anyone able to elaborate/provide a better solution?

Any help is much appreciated.

Kind regards,
Ty

HTML:
Sub Pastepic()
Windows("BKBM Workbook.xlsm").Activate
ActiveSheet.Paste Destination:=Worksheets("Sheet1").Range("a4")


Range("A1:B2").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Re: HELP: Run-time error '1004': Pate method of worksheet class failed

The activesheet is probably messing with U. Not sure what sheet should be...
Code:
Windows("BKBM Workbook.xlsm").Activate
Sheets("Sheet1").Paste Destination:=Worksheets("Sheet1").Range("a4")
U can also do this....
Code:
Sheets("Sheet1").Range("A1:B2").Copy Destination:= Sheets("Sheet1").Range("A1").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
Which doesn't seem to make much sense... it copies and pastes to the same cell on the same sheet? Anyways, HTH. Dave
 
Last edited:
Upvote 0
Re: HELP: Run-time error '1004': Pate method of worksheet class failed

Thanks mate. I changed the code and tried it this morning. All seems to have gone well. Will monitor it over the next couple of days.
 
Upvote 0
Re: HELP: Run-time error '1004': Pate method of worksheet class failed

You are welcome. Thanks for posting your outcome. Dave
 
Upvote 0
Re: HELP: Run-time error '1004': Pate method of worksheet class failed

Hey Dave, no luck unfortunately today. The same error occurred. :confused:
 
Upvote 0
Re: HELP: Run-time error '1004': Pate method of worksheet class failed

Not sure what's going on but if your using this routine repeatedly, the clipboard will occasionally crash and produce random errors. You can trial this (32 bit install code)..
module code...
Code:
Public Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EmptyClipboard Lib "user32" () As Long
Public Declare Function CloseClipboard Lib "user32" () As Long
To operate, after pasting....
Code:
Application.CutCopyMode = False
OpenClipboard (0&)
EmptyClipboard
CloseClipboard
Good luck. Dave
 
Upvote 0

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top