Script to extract a list of all spelling errors in a document?
Do you know of a script, utility or method to extract a list of all spelling errors, according to InDesign’s spellchecking engine, detected inside a document or a bunch of documents?
Do you know of a script, utility or method to extract a list of all spelling errors, according to InDesign’s spellchecking engine, detected inside a document or a bunch of documents?
Here's a script that collects all words caught by the spell checker and places them in a new document. It's a horrible thing, very slow, and right up there in the top-10 of ugly solutions. But it works. It came out of a discussion a few years ago here
which petered out after a few exchanges.
(function () {
const props = app.spellPreferences.properties;
const spellWindow = app.menuActions.item ('$ID/Check Spelling...');
var typos = [];
var knownTypo = {};
function record (typo) {
if (!knownTypo[typo]) {
knownTypo[typo] = true;
typos.push (typo);
}
}
// Begin ----------------------------------------------
// Hide the layout window to speed things up
app.windows[0].minimize();
app.spellPreferences.properties = {
checkCapitalizedSentences: false,
checkCapitalizedWords: false,
checkRepeatedWords: false,
checkMisspelledWords: true
}
spellWindow.invoke();
if (!app.selection.length) { // No spelling errors, nothing to do
exit();
}
// If there's a typo, it's now selected
record (app.selection[0].contents);
var i = app.selection[0].index; // The location of the typo
spellWindow.invoke();
while (app.selection[0].index !== i) { // Stop when we catch the same word
i = app.selection[0].index;
record (app.selection[0].contents);
spellWindow.invoke(); // Go to the next typo
}
app.selection = null;
// Restore the layout window and the spell preferences
app.activate();
app.spellPreferences.properties = props;
// Create a new document and add the typos.
app.documents.add().textFrames.add ({
geometricBounds: app.documents[0].pages[0].bounds,
contents: typos.sort().join('\r'),
});
}());
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.