Share via

assigning custom dictionary with VB

Anonymous
2020-11-21T18:50:18+00:00

I am using Word  2019. I am using the following code to assign a custom dictionary:

Private Sub Document_Open()

With CustomDictionaries

   .ClearAll

   .Add FileName:="C:\GBL\EProject\Plants\Plants.dic"

   .ActiveCustomDictionary = CustomDictionaries(1)

End With

End Sub

However when I open the document it does not recognize the custom dictionary. I have to go in through the options button to highlight the custon dictionary in proofing.

How can I do this with code when opening the document

My e-mail is ******@verizon.net

Thanks

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2020-11-21T22:10:16+00:00

Greg, OK. I got it figured out. Once I deleted the line with the clear all, it works perfectly as well as my original code works as well

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2020-11-21T20:37:25+00:00

Here is the example in VBA documentation:

Dim dicCustom As Dictionary 
Application.CustomDictionaries.ClearAll 
Set dicCustom = Application.CustomDictionaries _ 
 .Add(FileName:="C:\Program Files" _ 
 & "\Microsoft Office\Office\Home.dic") 
Application.CustomDictionaries.ActiveCustomDictionary = dicCustom

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2020-11-21T21:37:29+00:00

    Sorry, it now doesn't seem to work. I closed and opened the document and it wouldn't work. I had the same problem I had to go in to the proofing to highlight the dictionary to get it to accept new words. I changed the code to the following to fit my scheme:

    Private Sub Document_Open()

    Dim dicCustom As Dictionary

    Application.CustomDictionaries.ClearAll

    Set dicCustom = Application.CustomDictionaries _

     .Add(FileName:="C:\GBL\EProject\Plants\Plants.dic")

    Application.CustomDictionaries.ActiveCustomDictionary = dicCustom

    End Sub

    Like before it made my custom dictionary the default but would allow me to use it until I highlighted it in the custom dictionary dialog box

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2020-11-21T21:13:15+00:00

    Thanks Greg. It seems to work I appreciate the help.

    I consider myself a power vb user in Excel and Access but never really got into Word. Maybe I am not looking in the right places but I am having a hard time finding info on VB and word. It seems to be scarce.

    I looked at your sight and found it very helpful. Thank you again

    Was this answer helpful?

    0 comments No comments
  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more