我正在使用Outlook 2013,并试图在打开的邮件中查找黄色突出显示的文本,并更改突出显示的颜色。查找并更改现有邮件中的highlightcolor
我的眼睛很差,而且当高光颜色为黄色时,我无法区分突出显示的文本。绿色很好,蒂尔也是......所以我想改变它。
我做到了,在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
然后,我试图使它在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
它不工作。
While .Execute
未被识别。它正确到
End With
如何打开Word的一个实例,复制你的邮件内容到Word文档,改变突出显示在那里,然后复制回来?我并不是说这很优雅,但由于缺乏文档/备选方案,这可能是最快捷的方式。 –
感谢Jean-François,但实际上,vba代码工作正常。我的错!我在一封实际收到的电子邮件中测试了Macro,意识到它没有被突出显示,但是它有一个黄色的背景色。 你可以想象我现在有多愚蠢...... 我没有找到一种方法来通过VBA来改变这种黄色的背景色...... – ericporlier
够公平的!然后你可能想删除这个问题。 –