Consulting

Results 1 to 3 of 3

Thread: Outlook Macro to Change Color of Body Text

  1. #1
    VBAX Newbie
    Joined
    Sep 2018
    Posts
    2
    Location

    Outlook Macro to Change Color of Body Text

    Hey!

    I am trying to write an Outlook (2010) macro which I think should be simple. All it would do is change the color of an entire (in-progress) email to BLACK. The reason I am adding this is because I use a bunch of templates that have RED text to indicate fields that need to be customized. So I would click this macro just before sending to finalize it.

    Here's what I have so far:
    Sub PerpareTemp()
    Dim body As String

    Set body = omailitem.body

    ActiveDocument.Range(0, 0).Select
    Selection.WholeStory
    Selection.Font.Color = wdColorBlack

    End Sub
    I am obviously new to VBA and trying to learn. I am running into difficulty with the basics. Every time I try to find help online, I seem to find plenty of stuff for Excel and Word, but not Outlook.

  2. #2
    What you need is the following, run from a button on the QAT (Quick Access Toolbar) or message ribbon.

    Sub GoBlack()
        On Error GoTo ErrHandler
        If TypeName(ActiveWindow) = "Inspector" Then
            If ActiveInspector.IsWordMail And ActiveInspector.EditorType = olEditorWord Then
                ActiveInspector.WordEditor.Range.Font.Color = &H0
            End If
        End If
    lbl_Exit:
        Exit Sub
    ErrHandler:
        Beep
        Resume lbl_Exit
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Newbie
    Joined
    Sep 2018
    Posts
    2
    Location
    You are amazing. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •