Reputation: 49
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
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:
how it works: used display colors are forced to relatively narrow consistent palette, so all expected contrasts pop out
.
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.
.
If this was not helpful, feel free to downwote :)
Upvotes: 1