Hi All
I'm trying to get Word to copy and paste the contents of a word document into a new outlook message and I can get it to work sometimes but other times I get the error:
Run-Time error '4605'
Method PasteAndFormat of object 'Selection' failed.
This is the script I use to do this. I can see it makes its way to the clipboard, but won't paste the rest of the way.
Sub EmailData()
'Sets document up as an email
Dim OutApp As Object
Dim OutMail As Object
Dim OutInsp As Outlook.Inspector
Dim WdApp As Word.Application
Dim OutDoc As Word.Document
Dim WdSel As Word.Selection
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = ""
.Subject = "Please Approve"
.Display
End With
Set OutInsp = OutMail.GetInspector
Set OutDoc = OutInsp.WordEditor
Set WdApp = OutDoc.Application
Set WdSel = WdApp.Selection
ActiveDocument.Range.Copy
With OutMail
WdSel.PasteAndFormat Type:=wdFormatOriginalFormatting
End With
Set WdSel = Nothing
Set OutInsp = Nothing
Set OutMail = Nothing
Set OutDoc = Nothing
Set WdApp = Nothing
Set OutApp = Nothing
End Sub
Thanks,
Dallas