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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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