使用Word的wdColorRed将颜色应用于Outlook邮件文本

时间:2017-03-16 17:01:39

标签: vba outlook outlook-vba

我正在使用Outlook Professional Plus 2010并尝试设置字体颜色。

有人可以提供线索吗?

Sub InsertText()
    Dim sText As String
    sText = "Myname" + Format(Now(), "mm/dd/yyyy") + ":"
    On Error GoTo ErrHandler
    If TypeName(ActiveWindow) = "Inspector" Then
        If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then

            Set oRng = ActiveInspector.WordEditor.Application.Selection.Range
            With oRng
              .Text = sText
              .Font.Color = wdColorRed
              .Font.Size = 11
              .Collapse wdCollapseEnd
              .Select
            End With
           'ActiveInspector.WordEditor.Application.Selection.TypeText sText
        End If
    End If
    Exit Sub
ErrHandler:
    Beep
End Sub

1 个答案:

答案 0 :(得分:0)

@Sorceri - 使用RGB(255,0,0)或Outlook.OlColor.olColorRed。

这对我有用..不知道办公室VBA对象受产品限制..