I have a protected worksheet that I want to copy to an email using a macro. I am currently using the following code:
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Sheets("Ordering").Select
Range("A1:H63").Select
Selection.Copy
With OutMail
.To = ""
.Cc = ""
.BCC = ""
.Subject = ""
.Display
End With
SendKeys "^({v})", True
Set OutMail = Nothing
Set OutApp = Nothing
This works most of the time. However, it seems to have a bit of a bug where a new email is created but the sheet isn't pasted. Instead, Excel tells me it can't do it because the sheet is protected.
I have tried changing the macro so that it unprotects before it selects and to protects after pasting but this just results in a new email with no sheet pasted.
I have tried adding a wait command before the protect command but this just results in a new email with no sheet pasted and the macro taking longer to end.
Any ideas?