Copy picture and remove event code

J

john.kreps

Background:
1. User clicks button that copies picture from a worksheet to the
clipboard (CopyReport routine).
2. User pastes clipboard to a new workbook.

Issue:
The pasted picture retains code attached to its click event
(Picture1_Click).

Question:
How can I modify the CopyReport code to remove the picture's
associated Picture1_Click routine when the picture is pasted to
another workbook. The code would need to appear within Picture1_Click.

TIA...

Sub CopyReport()

Application.ScreenUpdating = False

'Copy to pictures to clipboard
Sheet4.Select
ActiveSheet.Shapes.Range(Array("Picture 1", "Picture 2")).Select
Selection.Copy
Sheet2.Select

End Sub

Sub Picture1_Click()

If Not Sheet1.Visible Then
If MsgBox("Do you want to unhide the underlying report?",
vbYesNo, "Unhide Worksheet") = vbYes Then
Sheet1.Visible = xlSheetVisible
Else
Exit Sub
End If
Else
Sheet1.Activate
End If

End Sub
 
N

NickHK

You don't you paste code, so I assume you use .Paste. using .PasteSpecial
means the code is not included. Change to suit:

ActiveSheet.Shapes("Picture 1").Copy
ActiveSheet.PasteSpecial Format:="Picture (PNG)", Link:=False,
DisplayAsIcon:=False

NickHK
 

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

Top