徵兆
Microsoft Word 中的拼字和文法檢查程式不會檢查表單域中的文字。
原因
由於表單域文字會格式化為 [沒有校訂],因此拼字和文法檢查工具會忽略表單域中的文字。
解決方案
若要解決此問題,您可以使用下列宏來:
- 暫時取消保護表單。
- 變更表單域的語言。
- 執行拼字檢查或更新欄位。
- 重新保護表單,同時保留您在表單域中輸入的文字。
您可以使用此宏做為最後一個表單域的 On Exit 宏,以便在儲存表單之前先檢查拼字或更新欄位。
Sub FormsSpellCheck()
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
' Set the language for the document.
Selection.WholeStory
Selection.LanguageID = wdEnglishUS
Selection.NoProofing = False
' Perform Spelling/Grammar check.
If Options.CheckGrammarWithSpelling = True Then
ActiveDocument.CheckGrammar
Else
ActiveDocument.CheckSpelling
End If
' ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
End If
End Sub
其他相關資訊
Microsoft 提供的程式設計範例僅供說明之用,並不具任何明示或暗示的責任擔保。 這包括 (但不限於) 任何目的之適售性及適用性的暗示責任擔保。 本文假設您熟悉示範的程式設計語言,也熟悉用以建立和偵錯程序的工具。 Microsoft 技術支援工程師可以協助說明特定程序的功能,但不會修改這些範例以提供附加功能或建構程序來滿足您的特定需求。