Ok, so here I have a bit of conundrum. Here's the wordy version of what I am attempting:
- In a template I've already made in Outlook, open it up and drag some files in - one of which will be an Excel file.
- Open the Excel file and read to a predetermined last cell
- Copy the cells from the last row/column to the first cell, A1.
- Paste the cells previously copied in step 3 into the Outlook body
Number 4 is currently where my issues lie. Attached is the code
Const xlUp = -4162
'Needed to use the .End() method
 Sub Sample()
    Dim NewMail As MailItem, oInspector As Inspector
    Set oInspector = Application.ActiveInspector
    Dim eAttachment As Object, xlsAttachment As Object, i As Integer, lRow As Integer, lPriorRow As Integer, lCommentRow As Integer
    '~~> Get the current open item
    Set NewMail = oInspector.CurrentItem
    'Code given to me from a previous question
    Set eAttachment = CreateObject("Excel.Application")
    With NewMail.Attachments
        For i = 1 To .Count
            If InStr(.Item(i).FileName, ".xls") > 0 Then
                'Save the email attachment so we can open it
                sFileName = "C:/temp/" & .Item(i).FileName
                .Item(i).SaveAsFile sFileName
                eAttachment.Workbooks.Open sFileName
                With eAttachment.Workbooks(.Item(i).FileName).Sheets(1)
                    lCommentRow = .Cells.Find("Comments").Row
                    lPriorRow = .Cells.Find("Prior Inspections").Row
                    lRow = eAttachment.Max(lCommentRow, lPriorRow)
                    ' Weirdly enough, Outlook doesn't seem to have a Max function, so I used the Excel one.
                    .Range("A1:N" & lRow).Select
                    .Range("A1:N" & lRow).Copy
                    'Here is where I get lost; nothing I try seems to work
                    NewMail.Display
                End With
                eAttachment.Workbooks(.Item(i).FileName).Close
                Exit For
            End If
        Next
    End With
End Sub
I saw on another question a function that changes Range objects to HTML, but it doesn't work here since this Macro code is in Outlook, not Excel.
Any help would be appreciated.
 
     
     
    