VBA to add word list to Custom Dictionary

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
In Excel VBA this checks the Custom Dictionary for a word:

Sub myDicList()
Dim myWord$, myDic$

myDic = Application.SpellingOptions.UserDict

myWord = InputBox("Check the Dictionaries for the Word you enter below." & _
vbLf & vbLf & "Note: Your custom dictionary is currently set to:" & vbLf & _
" " & myDic, "Lookup Your Word!")

If myWord = "" Then GoTo myEnd

If Not Application.CheckSpelling(myWord, CustomDictionary:=myDic, IgnoreUppercase:=False) Then
MsgBox "Not in dictionary!"

Else
MsgBox "Is in dictionary!"

End If

myEnd:
End Sub


But, this next code only creates a dummy custom.dic and does not update the real user custom dictionary?

Sub add_Dic()
Dim myWord$

Close #1
Open Application.SpellingOptions.UserDict For Output As #1

myWord = Selection.Value

If Not IsEmpty(myWord) Then
Write #1, myWord

MsgBox myWord & ", was Added to the current custom dictionary: " _
& Application.SpellingOptions.UserDict
End If

Close #1

End Sub

Does anyone know if you can add words by code?

From help it points to WORD as a way, but could not get it there as well?

In WORD VBA this lists the Custom Dictionaries, but can't seem to add any words to it by code?

Sub myDicts()

For Each d In CustomDictionaries

If d.Name = Application.CustomDictionaries.ActiveCustomDictionary.Name Then
MsgBox "Active Dictionary: " & d.Path & Application.PathSeparator & d.Name
Else
MsgBox "InActive Dictionary: " & d.Path & Application.PathSeparator & d.Name
End If

d.Write "Relo"
Next d

End Sub


Any ideas on adding a list of words to an Office User Defined Custom Dictionary used by Spell-Check?

The key-word Scripting Dictionary is not checked by SpellCheck even though you can add to it by code?
 
Walt

See the code I posted.

And also see why you shouldn't create multiple threads.:)

I'm getting all confused.:eek:

I think we should try and stick to the thread with the data.
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
hi
I want to check ***anese spelling in excel using vba.
I use this code for it.
Cells.CheckSpelling SpellLang:=1041
but run time error 1004 is appear, not allow for SpellLang:=1041 (***anese DisLang code)
Please help me
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top