在VBA中更改文本的颜色

时间:2014-05-27 16:56:24

标签: excel vba excel-vba outlook

我需要改变以下颜色:'细胞(cell.Row," A")。值'细胞(cell.Row," E")。值为蓝色。

你能帮忙吗?

Sub Test1()

    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range
    Dim Test As String



    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "C").Value) = "yes" Then

            Set OutMail = OutApp.CreateItem(0)
            On Error Resume Next

             With OutMail
                .To = cell.Value
                .Subject = "TITLE" & " - " & Format(Now, "dd_mmmm_yyyy")

                .Body = Test & "Dear " & Cells(cell.Row, "A").Value _
                      & vbNewLine & vbNewLine & _
                        "Text1" & _
                        vbNewLine & vbNewLine & _
                        "Text2'" & Cells(cell.Row, "E").Value & "TEXT" & _
                        vbNewLine & vbNewLine & _
                        "TEXT3" & _
                        vbNewLine & vbNewLine & _
                        "TEXT4" & _
                        vbNewLine & vbNewLine & _
                        "TEXT5" & _
                        vbNewLine & vbNewLine & "Many thanks," & vbNewLine & vbNewLine & "DCX PMO Team"

                'Adding an attachment
                .Attachments.Add ("D:\Users\ABOHANNO\Desktop\Digital Transformation\tagging\DCX Sales Process.pptx")
                .Send  'Or use Display



            End With
            On Error GoTo 0
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

1 个答案:

答案 0 :(得分:0)

试试这个:

 cell.Resize(1,5).Font.Color = vbBlue