Hi,
I have some simple code to copy a sheet (an invoice form) as a picture to the clipboard for pasting into Outlook emails through a command button:
Sub ButtonCopy()
ActiveSheet.Range("A1:DG182").CopyPicture xlScreen, Format:=xlPicture
ActiveSheet.Paste
Selection.Width = 500
Selection.Height = 500
Selection.Copy
Selection.Delete
MsgBox "Invoice copied to clipboard." & vbNewLine & "" & vbNewLine & "Please paste (Rt Click or CTRL+V) in your existing email (with documents attached) from the supplier/office"
End Sub
It works exactly how I want it BUT only if the 'edit objects' option of the Protect Sheet function is unticked (which leaves the command buttons editable and a backdoor to the VBA which is bad news).
When ticked and fully protected it produces runtime error 1004 .. 'cannot paste the data' and the debugger highlights the 'ActiveSheet.Paste' line.
I've seen similar examples online but they all seem to deal with pasting the sheet into another sheet which doesn't help. I also tried using 'On Error Resume Next' and 'Application.CutCopyMode = False' which did allow me to fully protect the sheet without the 1004, but it only copied the currently highlighted box as a picture.
I feel the solution is close, but I've run out of ideas. Can anyone please help?
Many thanks in advance.
I have some simple code to copy a sheet (an invoice form) as a picture to the clipboard for pasting into Outlook emails through a command button:
Sub ButtonCopy()
ActiveSheet.Range("A1:DG182").CopyPicture xlScreen, Format:=xlPicture
ActiveSheet.Paste
Selection.Width = 500
Selection.Height = 500
Selection.Copy
Selection.Delete
MsgBox "Invoice copied to clipboard." & vbNewLine & "" & vbNewLine & "Please paste (Rt Click or CTRL+V) in your existing email (with documents attached) from the supplier/office"
End Sub
It works exactly how I want it BUT only if the 'edit objects' option of the Protect Sheet function is unticked (which leaves the command buttons editable and a backdoor to the VBA which is bad news).
When ticked and fully protected it produces runtime error 1004 .. 'cannot paste the data' and the debugger highlights the 'ActiveSheet.Paste' line.
I've seen similar examples online but they all seem to deal with pasting the sheet into another sheet which doesn't help. I also tried using 'On Error Resume Next' and 'Application.CutCopyMode = False' which did allow me to fully protect the sheet without the 1004, but it only copied the currently highlighted box as a picture.
I feel the solution is close, but I've run out of ideas. Can anyone please help?
Many thanks in advance.