
什麼宏可以開啟/關閉某些校對設定? (不幸的是,巨集錄製不會記錄設定變更)
我正在尋找一種方法來開啟/關閉 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