Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Script to extract a list of all spelling errors in a document?

Community Beginner ,
Jul 11, 2023 Jul 11, 2023

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?

TOPICS
Scripting
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 11, 2023 Jul 11, 2023

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

https://community.adobe.com/t5/indesign/how-to-compare-a-word-with-indesign-user-dictionary-words/m-p/10450665?page=1

which petered out after a few exchanges.

 

(function () {
  
  const props = app.spellPreferences.properties;
  const spellWindo
...
Translate
Mentor ,
Jul 11, 2023 Jul 11, 2023

https://redokun.com/blog/indesign-spell-check#scripts-check-document-indesign

 

>> List of misspelled words. Theunis DeJong developed this script that creates a list of all the words in your document that don't exist in the InDesign dictionary.

 

 

Remember, never say you can't do something in InDesign, it's always just a question of finding the right workaround to get the job done. © David Blatner
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2023 Jul 11, 2023

Thank you, but both scripts in linked as "List of misspelled words" in that page don't do (nor claim to do if I read their description in the subsequent page they can be downloaded from) what the page says. They gather all words in a document—also the ones spelled correctly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 11, 2023 Jul 11, 2023

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

https://community.adobe.com/t5/indesign/how-to-compare-a-word-with-indesign-user-dictionary-words/m-...

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'),
  });
  
}());

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2023 Jul 11, 2023

Awesome! Thank you so much, Peter, for the prompt response and for all your awesome scripts and shared knowledge!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Sep 11, 2024 Sep 11, 2024

I am guessing all of the text is in textframes. If so, the page number should be available with app.selection[0].parentTextFrames[0].parentPage.documentOffset. Unless I am misunderstanding the structure.

You need to add that to this line in whatever syntax you would like.

record (app.selection[0].contents);

Note that the documentOffset starts at 0 so it will be one less than the actual page number.

Maybe  something like this:

var page = parseInt(app.selection[0].parentTextFrames[0].parentPage.documentOffset)+1;
record(app.selection[0].contents + ": " + page);

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2024 Sep 11, 2024
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 11, 2024 Sep 11, 2024

On a PC - probably on a Mac as well - if there is WORD installed - it might be quicker to copy text to WORD and perform spellchecking there? WORD returns collection of all spellcheck errors. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines