Enviar tabla de excel en el cuerpo de un correo HTML creado por una macro

Solicito su ayuda nuevamente con un problema que no puedo resolver, tengo una macro que envía un correo a varios destinatarios con unos adjunto, pero quiero agregarle al cuerpo del correo los datos de una tabla pivote, esta es lamacro del correo:

Sub Mail()
Dim i, j As Integer
Dim LCorreo As String, Texto As String
Dim lista As Range, xxbloq As Range
Dim OutApp As Object, Correo As Object
Dim pvt As PivotTable
FileAdd = Sheet6.Range("AB1").Value
Ruta = ThisWorkbook.Path & "\"
Set lista = Sheet10.ListObjects("Table3").ListColumns(2).Range
For Each celda In lista
    LCorreo = LCorreo & "; " & celda.Value
Next celda
LCorreo = Right(LCorreo, Len(LCorreo) - 10)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set pvt = Sheet13.PivotTables("PivotTable4")
With pvt.TableRange1
    Set xxbloq = .Cells(.Rows.Count, .Columns.Count)
End With
LastV = xxbloq.Value
If LastV >= 1 Then
    Texto = "Mensaje" & _
            "<br>" & "mensaje:"
            pvt.TableRange1.Copy
            Else
            Texto = ""
End If
'Comprobar si Outlook esta abierto y en caso de no estarlo abrirlo
On Error Resume Next
Set OutApp = GetObject("", "Outlook.Application")
Err.Clear
If OutApp Is Nothing Then Set OutApp = CreateObject("Outlook.Application")
OutApp.Visible = True
Set Correo = OutApp.CreateItem(0)
'Crear el correo y mostrarlo
With Correo
    .To = LCorreo
    .Subject = "Reporte diario de PNC y Proceso fuera de estándar"
    .HTMLBody = "Buenos días, " & "<br>" & _
                "Les adjunto el reporte diario. " & "<br>" & _
                Texto & _
                "<br>" & _
                "<br>" & "Saludos."
    .Display
    .attachments.Add Ruta & FileAdd & ".pdf"
    .attachments.Add Ruta & "Detalle de etiquetas bloqueadas" & ".xlsx"
End With
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub

Sin embargo, no puedo pegar la tabla seleccionada.

Respuesta
2

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas