0

I am using Outlook Professional Plus 2010 and trying to set the Font color.

Someone can give a clue?

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
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • I don't see anything wrong with your code- Are getting any errors? - try removing `on error goto` and test it also are working on ActiveExplorer or activewindow – 0m3r Mar 16 '17 at 21:10
  • 2
    @0m3r Outlook will not know the enumerations for word. The user can use RGB(255,0,0) or Outlook.OlColor.olColorRed – Sorceri Mar 16 '17 at 21:15
  • Aa maybe but looking at OPs Code he is already set up on word. – 0m3r Mar 16 '17 at 21:44
  • 1
    @0m3r Outlook uses word as the editor and there is no ActiveInspector object in word. – Sorceri Mar 16 '17 at 21:59
  • Add a reference to Word http://stackoverflow.com/a/24263432/1571407 so wdColorRed is understood. – niton Mar 17 '17 at 00:18

1 Answers1

0

@Sorceri - use RGB(255,0,0) or Outlook.OlColor.olColorRed .

This worked for me.. Didn't know office VBA objects are limited by products..