Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-30-2016, 08:02 AM
RealmOfCOnfusion RealmOfCOnfusion is offline VBA to change font colour in email body on send Windows 7 64bit VBA to change font colour in email body on send Office 2007
Novice
VBA to change font colour in email body on send
 
Join Date: Jun 2016
Posts: 1
RealmOfCOnfusion is on a distinguished road
Default VBA to change font colour in email body on send

With the help of some Excel VBA gurus I've managed to get some code that changes a specific font colour in the body of any email to black before the email is sent.

(Background: We have an employee who is dyslexic and finds it much easier to read characters on screen when the font colour is set to pink, so this code - see below - changes that specific colour to black when the user clicks on Send).

Code:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    If TypeName(Item) <> "MailItem" Then Exit Sub
    Item.HTMLBody = Replace(Item.HTMLBody, "#FF0066", "#000000", Compare:=vbTextCompare)
End Sub
This works fine, but she's now advised that she sometimes likes to amend the font colour from time to time (she seems to have some sort of variable dyslexia!), so what I need is something to change all of the text in the body of the email to black, rather than just replacing the one specific colour which is what the code above does.

Any suggestions?
Reply With Quote
  #2  
Old 06-30-2016, 09:55 PM
gmayor's Avatar
gmayor gmayor is offline VBA to change font colour in email body on send Windows 10 VBA to change font colour in email body on send Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following will do that

Code:
Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olInsp As Outlook.Inspector
Dim wdDoc As Object
Dim oRng As Object
    With Item
        Set olInsp = .GetInspector
        Set wdDoc = olInsp.WordEditor
        Set oRng = wdDoc.Range
        oRng.Font.ColorIndex = &H0&
    End With
lbl_Exit:
    Set olInsp = Nothing
    Set wdDoc = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to change font colour in email body on send Macro to change font in email, dependent on which email account is being used gb82 Outlook 2 01-23-2016 01:54 AM
VBA to change font colour in email body on send Send as PDF button in Word Body wordJohn Word 1 03-24-2015 04:29 AM
VBA to change font colour in email body on send Format email body-Using Excel VBA to send mail Claytocb Excel Programming 1 01-31-2013 11:58 PM
VBA to change font colour in email body on send Change font colour when tasks are completed meileetan Project 3 09-12-2012 07:09 AM
Font Change when I send to Coworker magictoaster Word 1 05-31-2012 02:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:22 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft