dudematters21
New Member
- Joined
- Oct 12, 2024
- Messages
- 14
- Office Version
- 365
Hello Masters,
Trying to convert column A1:A22 to plain text then paste it as an outgoing email in Outlook..
I tried this vba below, and Yes it converted everything to text
however it doesnt have proper spacing and paragraph anymore.. basically just the output is a straight text line.
Trying to convert column A1:A22 to plain text then paste it as an outgoing email in Outlook..
I tried this vba below, and Yes it converted everything to text
however it doesnt have proper spacing and paragraph anymore.. basically just the output is a straight text line.
VBA Code:
Sub Email_test()
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Set rng = Nothing
Set rng = Sheets("Shirts").Range("A1:A22").SpecialCells(xlCellTypeVisible)
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected. " & _
vbNewLine & "Please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Dim v As Variant: v = rng.Value
Dim tempStr As String: tempStr = ""
For i = LBound(v, 1) To UBound(v, 1)
For j = LBound(v, 2) To UBound(v, 2)
If j = 2 Then
tempStr = tempStr & v(i, j) & vbCrLf
Else
tempStr = tempStr & v(i, j) & " "
End If
Next j
Next i
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "[EMAIL]User@company.com[/EMAIL]"
.CC = ""
.BCC = ""
.Subject = "Cells as text "
.body = tempStr
.Display
End With
End Sub
Attachments
Last edited by a moderator: