首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Outlook VBA宏忽略选定文本块中的拼写错误

Outlook VBA宏忽略选定文本块中的拼写错误
EN

Stack Overflow用户
提问于 2018-04-12 18:49:51
回答 3查看 1.5K关注 0票数 1

在撰写一封包含大量编程术语的电子邮件时,我希望我的一般拼写错误能以红色的方式显示出来,但当许多特殊的单词也显示为错误时,它会变得很烦人。我可以运行通过拼写检查,并告诉它‘忽略所有’的每一个拼写事件,和红色的混乱将消失。然后,当我继续撰写消息时,拼写检查继续在新编辑上工作。

我想要做的是创建一个VBA宏,它将在选定的文本或整个消息正文中为我执行此操作(我没有首选项)。我是一名经验丰富的Access VBA开发人员,但不太熟悉Outlook中的拼写检查对象模型。

我的想法来自于免费的微软OneNote Onetastic外接程序“无拼写检查”宏。如果能在Outlook中做到这一点,那就太好了。

EN

Stack Overflow用户

发布于 2018-04-25 13:06:09

谢谢你的回答,这对我有很大帮助

另一个选项是在键入选项时切换检查克/拼写的显示。

下面是与你的答案不同的3行,第3行刷新“应用程序”(编辑器)一词。

我在Word本身的宏按钮中使用这3行

代码语言:javascript
运行
复制
oDoc.Application.Options.CheckGrammarWithSpelling = Not oDoc.Application.Options.CheckGrammarWithSpelling
oDoc.Application.Options.CheckSpellingAsYouType = Not oDoc.Application.Options.CheckSpellingAsYouType
oDoc.Application.ScreenRefresh

以下是完整宏

代码语言:javascript
运行
复制
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 Sub
票数 1
EN
查看全部 3 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49803910

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档