ericporlier
ericporlier

Reputation: 49

Find and change highlightcolor in existing mail

I am using Outlook 2013, and trying to find yellow highlighted text in an opened mail, and to change the highlighting color.

My eyes are bad, and I have trouble distinguishing highlighted text when the highlight color is yellow. Green is good, Teal too... so I wish to change it.

I did it in Word 2013.

Sub changer_jaune() 'change_yellow()
  Dim txt_hl As Range
  With Selection.Find
    .Highlight = True
    .Forward = True
    .Wrap = wdFindContinue
    While .Execute
      Set txt_hl = Selection.Range
      If txt_hl.HighlightColorIndex = wdYellow Then
        txt_hl.HighlightColorIndex = wdTeal 'wdTurquoise
        ' dark : wdTeal wdGreen
        ' too dark : wdViolet wdBlue
      End If
    Wend
  End With
End Sub

Then, I tried to make it work in Outlook:

Sub change_jaune_PR_COPIE()
Dim objItem As Object
Dim objInsp As Outlook.Inspector

'Reference the current Outlook item
Set objItem = Application.ActiveInspector.CurrentItem
If Not objItem Is Nothing Then
    If objItem.Class = olMail Then
        Set objInsp = objItem.GetInspector
        If objInsp.EditorType = olEditorWord Then

           'I switch to Edit Mode to be able to change the opened incoming mail
           'I would like to check for this before switching... But I don't know how...
           objInsp.CommandBars.ExecuteMso ("EditMessage")

           Set objDoc = objInsp.WordEditor
           Set objWord = objDoc.Application
           Set objSel = objWord.Selection

     With objWord.Selection.Find
        .Highlight = True
        .Forward = True
        .Wrap = wdFindContinue
        'While .Execute
          Set txt_hl = objWord.Selection.Range
          If txt_hl.HighlightColorIndex = wdYellow Then
            txt_hl.HighlightColorIndex = wdTeal 'wdTurquoise
            ' dark : wdTeal wdGreen
            ' too dard : wdViolet wdBlue
          End If
        'Wend
      End With

        End If
    End If
End If

'Saving the changes on this specific mail (which actually never occurs!!!)
objItem.Save

Set objItem = Nothing
Set objWord = Nothing
Set objSel = Nothing
Set objInsp = Nothing

End Sub

It doesn't work.

While .Execute

is not recognized. It goes right to

End With

Upvotes: 4

Views: 952

Answers (1)

miroxlav
miroxlav

Reputation: 12184

I know this answer might look a bit off-topic but I'm seeking way to help you effectively. I'm sorry to hear your eyes are very bad. I would suggest switching to High Contrast Mode instead of tweaking colors in particular applications. From my own experience with bad eyes, it has several advantages over your programmatic solution:

  • it is a full-stack solution for all applications you use, not only for Outlook
  • how it works: used display colors are forced to relatively narrow consistent palette, so all expected contrasts pop out

    • in Outlook, highlight color gets clearly distinguished from the background and this is true for most of other applications (this is the effect you seem to be seeking for)
    • ALL colors of the palette can be customized what gives advantage over modern Windows colors schemes (Windows 7 and 8), where for example you cannot change white background of windows to another color (it is possible only in classic color schemes with Windows 98 look)
      • there are 6 High Contrast schemes in Windows 8, and you can create your own
      • the only color I would change by default is either Windows Background or Button Background because they are set to same color and if you distinguish them, UI can get even more readable. I usually use modified High Contrast Scheme #1 (dark) with Windows Background adjusted to RGB 60,60,60 (decimal).

.

  • you can easily enable/disable High Contrast mode by pressing (left)Alt+Shift+PrtScr

  • some applications might need restart to adapt all their colors properly to High Contrast mode. The problem is on their side. Some amateurish applications might not support High Contrast mode at all. All major applications I tried work relatively well.

    • in most cases, it is the web browser which needs a restart, also let's name SQL Server Management Studio
    • an intended feature of High Contrast mode is that all background images are removed to achieve higher readability of foreground text. But if some web pages use background images in the role of main controls, they won't be displayed. For example, you won't see upvote/downwote buttons on this site...

.

  • High Contrast modes with dark backgrounds are ideal even for people with healthy eyes as night mode. I'm using it this way. Dark background is much easier on eyes when working at night. Think of car drivers switching their navigation unit to night colors when there is dark outside.

If this was not helpful, feel free to downwote :)

Upvotes: 1

Related Questions