InDesign Check Spelling without launching Spell Check?

Is there any way to have InDesign check spelling via a script and list any misspelled words via the script? Similarly, if there were no found spelling errors, then the script could return a prompt, i.e., “No Spelling Issues Found”.

You might ask why?

I have created a somewhat robust preflight-like script that checks for common issues specific to our guidelines, e.g., low resolution files, modified links, objects set to 100% black, overset text frames, etc.

It was suggested that it would be nice to have this also execute a spell check, without having to leave the script and launch InDesign’s spell check. But I could not find any method to do so.

If it’s not possible, that’s fine too. I could have the script ask, “Would you like to check Spelling and then run this script again.” buttons {“Yes”, “No”}.

But ideally, I would like to incorporate the spell check into the script so that it would never have to leave the script and then could jump to the next routine that does other quality checks.

Just curious if there is such a way?

Thanks,
-Jeff

I don’t think there’s a way in InDesign. However, you could extract the stories and check them using the system spelling checker:

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

my dodgyWordsIn:"Is there any way to have InDesign check spelling via a script and list any misspelled words via the script? Similarly, if there were no found speling errors, then the script could return a prompt, i.e., \"No Spelling Issues Found\"."

on dodgyWordsIn:theString
	set anNSString to current application's NSMutableString's stringWithString:theString
	set theChecker to current application's NSSpellChecker's sharedSpellChecker()
	theChecker's setLanguage:"en_AU" -- optional
	set theProblems to theChecker's checkString:anNSString range:{0, anNSString's |length|()} |types|:(current application's NSTextCheckingTypeSpelling) options:(missing value) inSpellDocumentWithTag:0 orthography:(missing value) wordCount:(missing value)
	set susWords to {}
	repeat with aFind in theProblems
		set end of susWords to (anNSString's substringWithRange:(aFind's range())) as text
	end repeat
	return susWords
end dodgyWordsIn:

Wow! Thank you very much once again Shane, this might actually do the trick!

-Jeff