This is to copy a range from Excel and send by email.
here i am getting an error 'Error 4605 - this method or property is not available because the document is locked for editing'
Code:
Application.ScreenUpdating = FalseDim Rng As Range
Dim xInspect As Object
Dim pageEditor As Object
Set myApp = New Outlook.Application
Set myMail = myApp.CreateItem(olMailItem)
Set sh3 = Sheet2
sh3.Unprotect
Set Rng = sh3.Range("B2:K22").SpecialCells(xlCellTypeVisible)
Selection.Copy
With myMail
Application.CutCopyMode = True
.Subject = "Hi"
.Body = "Dear " & vbCrLf & vbCrLf
.Display
Set xInspect = myMail.GetInspector
Set pageEditor = xInspect.WordEditor
sh3.Range("B2:L21").Copy
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteandFormat Type:=wdFormatOriginalFormatting
.Display
'.Send
Set pageEditor = Nothing
Set xInspect = Nothing
End With
Application.CutCopyMode = False
Set myMail = Nothing
Set myApp = Nothing
Application.ScreenUpdating = True
here i am getting an error 'Error 4605 - this method or property is not available because the document is locked for editing'
Code:
pageEditor.Application.Selection.PasteandFormat Type:=wdFormatOriginalFormatting