Solgar
01-23-2007, 05:57 AM
Hi,
I'm trying to turn on the "Check Spelling As You Type" option in by using VBA code in a Word Template that is distributed and installed on users PC's. I have put the following code in a sub that is called from autonew in the Word Template.
Sub spellcheck()
Dim returnValue As Variant
Dim dictionaryCustom As Dictionary
Dim FullDictionaryPath As Variant
Set dictionaryCustom=Application.CustomDictionaries.ActiveCustomDictionary
returnValue = CustomDictionaries.ActiveCustomDictionary.Path
FullDictionaryPath = returnValue + "\" + dictionaryCustom
With Options
.CheckSpellingAsYouType = True
.CheckGrammarAsYouType = True
End With
ActiveDocument.ShowGrammaticalErrors = True
ActiveDocument.ShowSpellingErrors = True
Languages(wdEnglishUK).SpellingDictionaryType = wdSpelling
With CustomDictionaries
.ClearAll
.Add(FullDictionaryPath).LanguageSpecific = False
.ActiveCustomDictionary = CustomDictionaries.Item(FullDictionaryPath)
End With
End Sub
When I change "Check Spelling As You Type" option to unchecked and then open the template or run the code the "Check Spelling As You Type" option is checked but when I type some garbage into the document the spelling mistakes are not underlined with the normal red wavy line.
Does anyone have any idea what I'm doing wrong ?
Many thanks,
Solgar
I'm trying to turn on the "Check Spelling As You Type" option in by using VBA code in a Word Template that is distributed and installed on users PC's. I have put the following code in a sub that is called from autonew in the Word Template.
Sub spellcheck()
Dim returnValue As Variant
Dim dictionaryCustom As Dictionary
Dim FullDictionaryPath As Variant
Set dictionaryCustom=Application.CustomDictionaries.ActiveCustomDictionary
returnValue = CustomDictionaries.ActiveCustomDictionary.Path
FullDictionaryPath = returnValue + "\" + dictionaryCustom
With Options
.CheckSpellingAsYouType = True
.CheckGrammarAsYouType = True
End With
ActiveDocument.ShowGrammaticalErrors = True
ActiveDocument.ShowSpellingErrors = True
Languages(wdEnglishUK).SpellingDictionaryType = wdSpelling
With CustomDictionaries
.ClearAll
.Add(FullDictionaryPath).LanguageSpecific = False
.ActiveCustomDictionary = CustomDictionaries.Item(FullDictionaryPath)
End With
End Sub
When I change "Check Spelling As You Type" option to unchecked and then open the template or run the code the "Check Spelling As You Type" option is checked but when I type some garbage into the document the spelling mistakes are not underlined with the normal red wavy line.
Does anyone have any idea what I'm doing wrong ?
Many thanks,
Solgar