Help me fix "Paste method of Worksheet class failed" Error :(

rhaas128

Board Regular
Joined
Jul 5, 2013
Messages
84
Below is the code I have for removing shapes and then copy/paste an image from one sheet to another in a specific cell. I am inconsistently getting the error 1004 paste method of worksheet class failed error. Any recommendations are greatly appreciated!

Code:
Public Sub fillPicture(inputValue)
    
    Dim shownPicture
    Dim listedPicture
    
    For Each shownPicture In Worksheets(3).Shapes
        If shownPicture.Type = msoPicture Then
            shownPicture.Delete
        End If
    Next shownPicture
    
    For Each listedPicture In Worksheets(8).Shapes
        If LCase(Trim(listedPicture.Name)) = LCase(Trim(inputValue)) And listedPicture.Type = msoPicture Then
            
            listedPicture.Copy
            Worksheets(3).Paste Worksheets(3).Cells(27, 1)
            
        End If
        
    Next listedPicture
End Sub
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Replaces this:

Code:
If LCase(Trim(listedPicture.Name)) = LCase(Trim(inputValue)) And listedPicture.Type = msoPicture Then
      listedPicture.Copy
      Worksheets(3).Paste Worksheets(3).Cells(27, 1)
End If

With this:

Code:
If LCase(Trim(listedPicture.Name)) = LCase(Trim(inputValue)) And listedPicture.Type = msoPicture Then
    listedPicture.Copy Worksheets(3).Cells(27, 1)
    Application.CutCopyMode = False
End If
 
Last edited:
Upvote 0
Any other suggestions? I have been searching Google and trying different things but can't seem to get any of them to not produce an error.
 
Upvote 0
Would I need to use a selection before pasting the image? I have tried a few variations of that as well, but not having any luck. Perhaps someone with more knowldege may be able to provide guidance...
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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