Outlook VBA 宏忽略所选文本块中的拼写错误 [英] Outlook VBA macro to Ignore Spelling Errors in Selected Block of Text

查看:44
本文介绍了Outlook VBA 宏忽略所选文本块中的拼写错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在撰写包含大量编程术语的电子邮件时,我希望我的一般拼写错误显示为红色波浪线,但当许多特殊单词也显示为错误时,这会很烦人.我可以运行拼写检查并告诉它对每个拼写事件全部忽略",红色波浪线就会消失.然后,当我继续撰写邮件时,拼写检查会继续处理新的编辑内容.

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

我对此的想法来自免费的 Microsoft OneNote

When composing an email that contains a lot of programming terms I want my general spelling errors to show up with a red squiggle but it gets annoying when a lot of special words also show as errors. I can run through the spell check and tell it to 'Ignore All' for each spelling incident and the red squiggles will go away. Then as I continue composing the message the spell check continues to work on new edits.

What I'd like to do is create a VBA macro that will do this for me in the selected text or the entire message body (I don't have a preference). I'm an experienced Access VBA developer but not too familiar with the Spell Check object model in Outlook.

My idea for this came from the free Microsoft OneNote Onetastic add-in and the "No Spell Check" macro. It would be great to be able to do this in Outlook.

解决方案

With a kick start from BigBen I was able to answer this question. I gave him the check mark but this is the function I think answers my question. (Edit: now that I see how this response is laid out I checked this answer.)

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

If you want to add this function to your message toolbar, open the Quick Access Toolbar when you have a message window open (not the main Outlook window). Follow the arrows in the image below.

这篇关于Outlook VBA 宏忽略所选文本块中的拼写错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆