Well, you could edit the IDML...
1 person found this helpful
Sorry, I have not the answer. Really boring issue!
From what I can understand, the whole problem is in the way app.findTextPreferences.appliedLanguage validates input. The error message that ExtendScript returns ("Invalid value for set property 'appliedLanguage'. Expected XXX, but received XXX") is automatically and stupidly generated at runtime, but of course it does not say the actual reason for the failure. I think the actual reason is that app.findTextPreferences.appliedLanguage attempts to match the supplied value against a app.LanguagesWithVendors item. The “invalid” language you want to supply is, in fact, valid from the document perspective—in the sense that it regularly belongs to myDoc.languages, has an id, can be applied to text, etc., even though ID does not support that language—but it is not valid from the application perspective (app.LanguagesWithVendors cannot see that item).
This should not be a problem, since app.findTextPreferences usually supports properties which may be only resolved within a specific document— e.g. app.findTextPreferences.appliedCharacterStyle, etc. Unfortunately, app.findTextPreferences.appliedLanguage does not seem to implement the usual specifier resolution mechanism and sounds to expect a value that the application can see in its own language collection (app.LanguagesWithVendors). This is especially frustrating as the F&R dialog box, in InDesign, perfectly displays every document-specific language and allows the user to select it!
Yes, I figured so much from the difference between those 'vendors' and plain 'language'. Perhaps Adobe should have made FindTextPreferences a Document option, rather than Application.
I think I'm going to try to loop over textstyleranges and see how (slow) that goes.
Perhaps Adobe should have made FindTextPreferences a Document option, rather than Application.
I so agree with you. Restricting FindTextPreferences to the Application scope was a serious design mistake, since the corresponding findText(), findGrep()... methods are available at any sublevel.