I have a script to copy a table into an email and want to have a couple lines before the table. I have tried several different methods but when it pastes the table it pastes it at the very beginning. Thank you for your help.
Sub copy_email()
'
' copy_email Macro
' Keyboard Shortcut: Ctrl+e
Dim OutApp As Object
Dim OutMail As Object
Dim table As Range
Dim pic As Picture
Dim ws As Worksheet
Dim wordDoc
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Dim rng As Range
Set ws = ThisWorkbook.Sheets("Sheet1")
Set rng = ws.Range("A1:I27")
With OutMail
.To = "to"
.Subject = "test"
.Display
.HTMLBody = "test test"
Dim wdDoc As Object '## Word.Document
Dim wdRange As Object '## Word.Range
Set wdDoc = OutMail.GetInspector.WordEditor
Set wdRange = wdDoc.Range(0, 0)
wdRange.InsertAfter vbCrLf & vbCrLf
'Copy the range in-place
rng.Copy
wdRange.Paste
End With
On Error GoTo 0
Range("A1").Select
Set OutApp = Nothing
Set OutMail = Nothing
End Sub
Bookmarks