Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Basic and Word Spellchecker in different Language

Status
Not open for further replies.

Zestman

Programmer
Mar 13, 2003
10
ZA
Hi All

Ive set up a different language in MS Word to check my "Afrikaans" spelling. It works fine in Word, but when I create a simple program :

Dim w As New Word.Application

Private Sub Command1_Click()

If w.CheckSpelling(Text1.Text) Then
MsgBox "Correct Spelling"
End If
End Sub

it only uses the english dictionary and doesnt check afrikaans words.

Inside Word I have set the Afrikaans Dictionary to be the default one. I can also not use

w.language = "Afrikaans"

because it gives an error stating that I cannot change a read only property

Any help ??
 
i think you need to specify any other languages (but i could be wrong)

the full call for checkspelling is

CheckSpelling(Word As String, [CustomDictionary], [IgnoreUppercase], [MainDictionary], [CustomDictionary2], [CustomDictionary3], [CustomDictionary4], [CustomDictionary5], [CustomDictionary6], [CustomDictionary7], [CustomDictionary8], [CustomDictionary9], [CustomDictionary10])

if i am wrong apologies.

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
Thanks for the reply

Ive tried specifying it like :
If s.CheckSpelling(Text1.Text, , , "Afrikaans") Then

or
If s.CheckSpelling(Text1.Text,"Afrikaans") Then

but no luck..
does anyone maybe have the MSDN Help on the
.Checkspelling
function ?

if i ask the value of
s.language it gives me the value 1033
and I cannot change it (Read only)

:(
 
again going all out in blind fury...

the constant for the afrikaans dictionary(ie the dictionary language id) is:-

wdAfrikaans

sorry i cant be more specific but im learning as i help!!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
ok... i believe it is not considered good practice to paste from MSDN but since you have this problem...

check spelling info:-

Syntax 1: Begins a spelling check for the specified document or range. If the document or range contains errors, this method displays the Spelling and Grammar dialog box (Tools menu), with the Check grammar check box cleared. For a document, this method checks all available stories (such as headers, footers, and text boxes).

Syntax 2: Checks a string for spelling errors. Returns True if the string has no spelling errors.

Syntax 1

expression.CheckSpelling(CustomDictionary, IgnoreUppercase, AlwaysSuggest, CustomDictionary2 – CustomDictionary10)

Syntax 2

expression.CheckSpelling(Word, CustomDictionary, IgnoreUppercase, MainDictionary, CustomDictionary2 – CustomDictionary10)

expression Syntax 1: Required. An expression that returns a Document or Range object.

Syntax 2: Optional. An expression that returns an Application object.

Word Required String. The text whose spelling is to be checked.

CustomDictionary Optional Variant. Either an expression that returns a Dictionary object or the file name of the custom dictionary.

IgnoreUppercase Optional Variant. True if capitalization is ignored. If this argument is omitted, the current value of the IgnoreUppercase property is used.

AlwaysSuggest Optional Variant. True if Word always suggests alternative spellings. If this argument is omitted, the current value of the SuggestSpellingCorrections property is used.

MainDictionary Optional Variant. Either an expression that returns a Dictionary object or the file name of the main dictionary.

CustomDictionary2 – CustomDictionary10 Optional Variant. Either an expression that returns a Dictionary object or the file name of an additional custom dictionary. You can specify as many as nine additional dictionaries.
Syntax 1: Begins a spelling check for the specified document or range. If the document or range contains errors, this method displays the Spelling and Grammar dialog box (Tools menu), with the Check grammar check box cleared. For a document, this method checks all available stories (such as headers, footers, and text boxes).

Syntax 2: Checks a string for spelling errors. Returns True if the string has no spelling errors.

Syntax 1

expression.CheckSpelling(CustomDictionary, IgnoreUppercase, AlwaysSuggest, CustomDictionary2 – CustomDictionary10)

Syntax 2

expression.CheckSpelling(Word, CustomDictionary, IgnoreUppercase, MainDictionary, CustomDictionary2 – CustomDictionary10)

expression Syntax 1: Required. An expression that returns a Document or Range object.

Syntax 2: Optional. An expression that returns an Application object.

Word Required String. The text whose spelling is to be checked.

CustomDictionary Optional Variant. Either an expression that returns a Dictionary object or the file name of the custom dictionary.

IgnoreUppercase Optional Variant. True if capitalization is ignored. If this argument is omitted, the current value of the IgnoreUppercase property is used.

AlwaysSuggest Optional Variant. True if Word always suggests alternative spellings. If this argument is omitted, the current value of the SuggestSpellingCorrections property is used.

MainDictionary Optional Variant. Either an expression that returns a Dictionary object or the file name of the main dictionary.

CustomDictionary2 – CustomDictionary10 Optional Variant. Either an expression that returns a Dictionary object or the file name of an additional custom dictionary. You can specify as many as nine additional dictionaries.

dictionary object (word.dictionary) info

Represents a dictionary. Dictionary objects that represent custom dictionaries are members of the Dictionaries collection. Other dictionary objects are returned by properties of the Languages collection; these include the ActiveSpellingDictionary, ActiveGrammarDictionary, ActiveThesaurusDictionary, and ActiveHyphenationDictionary properties.

Using the Dictionary Object

Use CustomDictionaries(index), where index is an index number or the string name for the dictionary, to return a single Dictionary object that represents a custom dictionary. The following example returns the first dictionary in the collection.

CustomDictionaries(1)
The following example returns the dictionary named "MyDictionary."

CustomDictionaries("MyDictionary")
Use the ActiveCustomDictionary property to set the custom spelling dictionary in the collection to which new words are added. If you try to set this property to a dictionary that's not a custom dictionary, an error occurs.

Use the Add method to add a new dictionary to the collection of active custom dictionaries. If there's no file with the name specified by FileName, Word creates it. The following example adds "MyCustom.dic" to the collection of custom dictionaries.

CustomDictionaries.Add FileName:="MyCustom.dic"
Remarks

Use the Name and Path properties to locate any of the dictionaries. The following example displays a message box that contains the full path for each dictionary.

For Each d in CustomDictionaries
Msgbox d.Path & Application.PathSeparator & d.Name
Next d
Use the LanguageSpecific property to determine whether the specified custom dictionary can have a specific language assigned to it with the LanguageID property. If the dictionary is language specific, it will verify only text that's formatted for the specified language.

For each language for which proofing tools are installed, you can use the ActiveGrammarDictionary, ActiveHyphenationDictionary, ActiveSpellingDictionary, and ActiveThesaurusDictionary properties to return the corresponding Dictionary objects. The following example returns the full path for the active spelling dictionary used in the U.S. English version of Word.

Set myspell = Languages(wdEnglishUS).ActiveSpellingDictionary
MsgBox mySpell.Path & Application.PathSeparator & mySpell.Name
The ReadOnly property returns True for .lex files (built-in proofing dictionaries) and False for .dic files (custom spelling dictionaries).

lots of reading i know... but maybe it helps you!

good luck


If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
hello again: any luck??

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top