PDA

View Full Version : [SOLVED:] Outlook Macro to Change Color of Body Text



Rewenx
09-14-2018, 01:35 PM
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. :(

gmayor
09-14-2018, 08:16 PM
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

Rewenx
09-17-2018, 07:33 AM
You are amazing. Thank you.