Error 4605 - this method or property is not available because the document is locked for editing

vmjamshad

New Member
Joined
Jan 5, 2017
Messages
16
This is to copy a range from Excel and send by email.
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
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,912
Messages
6,175,340
Members
452,638
Latest member
Oluwabukunmi

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