所以从工作表通过用户窗体复制excel范围并将其粘贴到Outlook中时出现错误 错误4605出现,表明文档已被锁定以进行编辑 现在最奇怪的部分是-我第一次遇到此错误,但第一次却不了解-它来来去去-当我单击debug时-它将我带到页面编辑器行项之一
Private Sub Quoteiso9001_Click()
Dim outlook As Object
Dim newEmail As Object
Dim xInspect As Object
Dim pageEditor As Object
Set outlook = CreateObject("Outlook.Application")
Set newEmail = outlook.CreateItem(0)
With newEmail
.To = ""
.CC = ""
.BCC = ""
.Subject = Sheet1.Range("C6").Text
.Body = "Dear Valued Client" & vbCrLf & vbCrLf & "On behalf of SGS, we are delighted to provide you with an Estimate of Investment for ISO 9001:2015 Third Party Certification." & vbCrLf & "To meet your certification needs, I have enclosed an estimate of investment and timing for your review and consideration."
.display
Sheet1.Range("A8:G30").Copy
Set xInspect = newEmail.GetInspector
Set pageEditor = xInspect.WordEditor
pageEditor.Application.Selection.Start = Len(.Body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
.display
Set pageEditor = Nothing
Set xInspect = Nothing
End With
Set newEmail = Nothing
Set outlook = Nothing
End Sub
答案 0 :(得分:0)
尝试用下面的代码替换您的pageEditor
部分
pageEditor.Application.Selection.Start = Len(.body)
pageEditor.Application.Selection.End = pageEditor.Application.Selection.Start
.display
Application.Wait (Now + TimeValue("0:00:02"))
pageEditor.Application.Selection.PasteAndFormat (wdFormatPlainText)
.Send