InDesign: Delete Document Dictionary

320 Views Asked by At

I am having trouble deleting a document dictionary in InDesign CS 5.5.

InDesign Document Dictionary

I can clear the contents of a user dictionary using this script:

var myUserDictionaries = app.userDictionaries;
var myCountDict = myUserDictionaries.count();

for (var i = myCountDict-1; i >= 0; i-- ) {
    myUserDictionary = myUserDictionaries[i];
    var myAddedWords = myUserDictionary.addedWords;
    myUserDictionary.removeWord(myAddedWords);
}

But this leaves the document dictionary untouched. A few years ago, this was an unresolved problem as seen on the Adobe forums.

But I found this code (from here):

var myHyphenations = app.activeDocument.hyphenationExceptions;
for (var i = 0; i < myHyphenations.length; i++) {
    if (myHyphenations[i].name === "Danish") {
        var mySourceDictionary = myHyphenations[i];
        mySourceHyphenations = mySourceDictionary.addedExceptions;
        break
        }
    }

Which seems to be able to access the document dictionary. But my question is (since I'm not much of a programmer), how to modify this code to clear or delete the document dictionary (for English:USA)?

1

There are 1 best solutions below

3
On

Actually this turned out to be more simple than I anticipated.

Here's the script that will delete/clear a document dictionary:

var myHyphenations = app.activeDocument.hyphenationExceptions;
var myCountDict = myHyphenations.count();
for (var i = myCountDict-1; i >= 0; i-- ) {
    myHyphenation = myHyphenations[i];
    var myAddedWords = myHyphenation.addedExceptions;
    myHyphenation.removeException(myAddedWords);
    }