Hi,
Trying to copy a range to an outlook mail I've created. I've tried to implemenet some code found here http://stackoverflow.com/questions/2...l-as-a-picture but i'm getting a variable not defined error on the "wDoc.rng.PasteAndFormat Type:=wdPasteBitmap" line. I want to use late binding as I will be distributing the code. So far:
Sub SendMail(control As IRibbonControl)
Dim oOutlook As Object
Dim OutApp As Object
Dim OutMail As Object
Dim oInsp As Object
Dim wWord As Object
Dim wDoc As Object
Dim wsPath As String
Dim rng As Range
Dim qar As Worksheet
Set qar = ActiveWorkbook.Sheets("QAR_Report")
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0
If oOutlook Is Nothing Then
MsgBox "Outlook is not open, please open Outlook and try again."
Else
Set rng = qar.Cells(43, qar.Columns.Count).End(xlToLeft)
Set rng = Range("A3:" & rng.Address)
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set wWord = CreateObject("Word.Application")
Set oInsp = .GetInspector
Set wDoc = oInsp.WordEditor
rng.Copy
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Test"
.Body = ""
wDoc.rng.PasteAndFormat Type:=wdPasteBitmap
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End If
End Sub
Any ideas ?
Thanks,
amphi
Bookmarks