在撰写一封包含大量编程术语的电子邮件时,我希望我的一般拼写错误能以红色的方式显示出来,但当许多特殊的单词也显示为错误时,它会变得很烦人。我可以运行通过拼写检查,并告诉它‘忽略所有’的每一个拼写事件,和红色的混乱将消失。然后,当我继续撰写消息时,拼写检查继续在新编辑上工作。
我想要做的是创建一个VBA宏,它将在选定的文本或整个消息正文中为我执行此操作(我没有首选项)。我是一名经验丰富的Access VBA开发人员,但不太熟悉Outlook中的拼写检查对象模型。
我的想法来自于免费的微软OneNote Onetastic外接程序和“无拼写检查”宏。如果能在Outlook中做到这一点,那就太好了。
发布于 2018-04-16 20:30:02
从BigBen开始,我就能回答这个问题。我给了他支票,但这是我想回答我问题的函数。(编辑:现在我看到了这个响应是如何排列的,所以我检查了这个答案。)
Public Sub **ClearSpellCheckSquiggles**()
' Remove the red squiggles from the current document because they may be distracting
' while composing a message with a lot special words (like code).
' New text added after this runs will still be checked and indicated by red squiggles.
' This assumes that you also have Word installed on your box. If so, you can
' access most of the Word OM from the Outlook VBE *without* referencing Word
' by using the ActiveInspector.WordEditor object.
Dim oDoc As Object ' Word.Document ' Or add a reference to the Microsoft Word Object Library for IntelliSense
Dim oMail As Outlook.MailItem
If TypeOf Application.ActiveInspector.CurrentItem Is Outlook.MailItem Then
Set oMail = Application.ActiveInspector.CurrentItem
Else
Exit Sub
End If
Set oDoc = oMail.GetInspector.WordEditor
If Not (oDoc Is Nothing) Then
' Mark the current document as already spell-checked:
oDoc.SpellingChecked = True
' Mark the current document as already grammar-checked (green squiggles):
oDoc.GrammarChecked = True
End If
End Sub如果要将此函数添加到邮件工具栏中,请在打开邮件窗口(而不是主Outlook窗口)时打开“快速访问工具栏”。跟随下图中的箭头。


发布于 2018-04-12 21:25:27
相对于选定的文本,清除整个消息正文似乎更容易(至少也可能);希望这会给您一些启发。
请注意,假设您已经有拼写错误,消息正文不会立即用ShowSpellingErrors = False清除。切换语言是一种快速的攻击,但却是简单明了的。更多的想法这里。
Option Explicit
Sub Test()
' Add a reference to the Microsoft Word Object Library for this to compile
Dim oDoc As Word.Document
Dim oMail As Outlook.MailItem
If TypeOf Application.ActiveInspector.CurrentItem Is Outlook.MailItem Then
Set oMail = Application.ActiveInspector.CurrentItem
Else
Exit Sub
End If
Set oDoc = oMail.GetInspector.WordEditor
If Not (oDoc Is Nothing) Then
oDoc.ShowSpellingErrors = False
' Toggling the language forces a recheck of the body, to clear red squiggles
oDoc.Range.LanguageID = wdAfrikaans
oDoc.Range.LanguageID = wdEnglishUS
End If
End Sub发布于 2018-04-25 13:06:09
谢谢你的回答,这对我有很大帮助
另一个选项是在键入选项时切换检查克/拼写的显示。
下面是与你的答案不同的3行,第3行刷新“应用程序”(编辑器)一词。
我在Word本身的宏按钮中使用这3行
oDoc.Application.Options.CheckGrammarWithSpelling = Not oDoc.Application.Options.CheckGrammarWithSpelling
oDoc.Application.Options.CheckSpellingAsYouType = Not oDoc.Application.Options.CheckSpellingAsYouType
oDoc.Application.ScreenRefresh以下是完整宏
Public Sub ClearSpellCheckSquiggles()
' Remove the red squiggles from the current document because they may be distracting
' while composing a message with a lot special words (like code).
' New text added after this runs will still be checked and indicated by red squiggles.
' This assumes that you also have Word installed on your box. If so, you can
' access most of the Word OM from the Outlook VBE *without* referencing Word
' by using the ActiveInspector.WordEditor object.
Dim oDoc As Word.Document ' Or add a reference to the Microsoft Word Object Library for IntelliSense
Dim oMail As Outlook.MailItem
If TypeOf Application.ActiveInspector.CurrentItem Is Outlook.MailItem Then
Set oMail = Application.ActiveInspector.CurrentItem
Else
Exit Sub
End If
Set oDoc = oMail.GetInspector.WordEditor
If Not (oDoc Is Nothing) Then
' ' Mark the current document as already spell-checked:
' oDoc.SpellingChecked = True
'
' ' Mark the current document as already grammar-checked (green squiggles):
' oDoc.GrammarChecked = True
oDoc.Application.Options.CheckGrammarWithSpelling = Not oDoc.Application.Options.CheckGrammarWithSpelling
oDoc.Application.Options.CheckSpellingAsYouType = Not oDoc.Application.Options.CheckSpellingAsYouType
oDoc.Application.ScreenRefresh
End If
End Subhttps://stackoverflow.com/questions/49803910
复制相似问题