Änderung des VBA-Codes, um die Datenformatierung im Excel-Blatt vor dem Kopieren in Outlook beizubehalten

Änderung des VBA-Codes, um die Datenformatierung im Excel-Blatt vor dem Kopieren in Outlook beizubehalten

Ich habe ein VBA, das die Details aus einer Excel-Tabelle in den Text einer Outlook-E-Mail kopiert: Unten sehen Sie das Makro:

Sub Send_Email()

Dim EmailSubject As String
Dim SendTo As String
Dim EmailBody As String
Dim ccTo As String

EmailSubject = "Test"
SendTo = "[email protected]"


FirstRow = 1 
LastRow = 5
FirstCol = 1 
LastCol = 2 

For r = FirstRow To LastRow
For c = FirstCol To LastCol

For Each cell In Cells(r, c)
strtable = strtable & "  " & cell.Value
Next
Next
strtable = strtable & vbNewLine
Next

EmailBody = "Hi" & vbLf & vbLf & " body" & vbLf & vbLf & strtable & vbNewLine 

Set App = CreateObject("Outlook.Application")
Set Itm = App.CreateItem(0)
With Itm
.Subject = EmailSubject
.To = SendTo
.CC = ccTo
.Body = EmailBody
.Display
'.Send
End With
Set App = Nothing
Set Itm = Nothing
End Sub

Aber die Angaben in der Excel-Tabelle sind tabellarisch und teilweise formatiert. Können die Tabelle und die Formatierung beibehalten werden, wenn die Daten in Outlook kopiert werden? Wenn ja, wie?

verwandte Informationen