什么宏可以打开/关闭某些校样设置?(不幸的是,宏录制不会记录设置的更改)
我正在寻找一种方法来(同时)打开/关闭 2 个校对设置:
- 键入时检查拼写
- 在输入时标记语法错误
答案1
Application.Options.CheckGrammarAsYouType 和 .CheckSpellingAsYouType 就是您要找的。
例子:
Sub GrammarSpellingOn()
Application.Options.CheckGrammarAsYouType = True
Application.Options.CheckSpellingAsYouType = True
End Sub
Sub GrammarSpellingOff()
Application.Options.CheckGrammarAsYouType = False
Application.Options.CheckSpellingAsYouType = False
End Sub
要使用相同的宏来打开/关闭,并弹出窗口说明更改已完成:
Sub GrammarSpellingOnOff()
If Application.Options.CheckGrammarAsYouType = True Or Application.Options.CheckSpellingAsYouType = True Then
Application.Options.CheckGrammarAsYouType = False
Application.Options.CheckSpellingAsYouType = False
Call MsgBox("Grammar & Spell Checking turned OFF")
Else
Application.Options.CheckGrammarAsYouType = True
Application.Options.CheckSpellingAsYouType = True
Call MsgBox("Grammar & Spell Checking turned ON")
End If
Application.ScreenRefresh 'refresh to add/remove spellchecker underlines
End Sub
答案2
所以我的设置略有不同。我主要在编写包含代码的演示文稿时使用它。我已将宏分配给键,以下是两个宏:
这将忽略所有校对,从而摆脱 Word 中那些烦人的标记
Sub CodeFont()
'
' CodeFont Macro
' Change font to differentiate code
'
Selection.Font.Name = "Consolas"
Selection.Font.Size = 11
Selection.Font.ColorIndex = wdBlue
Selection.NoProofing = True
End Sub
当我想恢复“正常”打字时
Sub Normal()
'
' Normal Macro
'
'
Selection.Font.Name = "Times New Roman"
Selection.Font.Size = 12
Selection.Font.ColorIndex = wdBlack
Selection.NoProofing = False
End Sub