Petr,
Following is some code I use to add to a dictionary. To do this, you have
to open the .DIC file as text and manually add a paragraph with the word you
want to add.
Sub AddAcronym()
Dim newAcr As String, dicfile As String, AcroList As Document
'word to be added is selected in document; trim extra spaces
newAcr = vbCr & Trim(Selection.Words(1).Text)
dicfile = "C:\tools\macros\powertools\acronymlist.dic"
'open the dictionary file
Set AcroList = Documents.Open(FileName:=dicfile, _
ConfirmConversions:=False, AddToRecentFiles:=False, Revert:=False, _
Format:=wdOpenFormatText)
With AcroList.Content
'Do a search to ensure word is not already in dictionary
With .Find
.ClearFormatting
.Forward = True
.MatchCase = True
.MatchWholeWord = True
.Wrap = wdFindStop
.Text = newAcr
.Execute
If .Found Then GoTo SkipAdd
End With
'add the new word to the end of the word list, then sort the whole
list
.InsertAfter vbCr & newAcr
.Sort ExcludeHeader:=False, FieldNumber:="Paragraphs", _
SortFieldType:=wdSortFieldAlphanumeric,
SortOrder:=wdSortOrderAscending
End With
'save the dictionary file without adding to the file MRU list
AcroList.SaveAs FileFormat:=wdFormatText, AddToRecentFiles:=False
SkipAdd:
AcroList.Close
End Sub
Hope that helps
Regards,
Chad