Change doubleQuotes using javascript
Copy link to clipboard
Copied
Good Morning and Happy new Year.
I'm trying to change the preference of double quotes with javascript, my code is:
var languages= activeDoc.languages;
if (languages != null) {
var language= languages[0];
language.doubleQuotes = '””'
}
but this code don't run.
Does anyone know how to change this preference?
thank you
Copy link to clipboard
Copied
Can't you use Find/Change, once for opening and once for closing quotation marks?
Copy link to clipboard
Copied
Hi @israelp20923262, since you are doing scripting, have a look at this snippet:
function main() {
// select some text, then run script
var doc = app.activeDocument,
text = doc.selection[0];
if (!text.hasOwnProperty('appliedLanguage')) {
alert('Please select some text and try again.');
return;
}
var lang = doc.languages.itemByName(text.appliedLanguage.name);
lang.doubleQuotes = "””";
}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set Language Quotes');
I think the key point is how you target the correct language. activeDoc.languages[0] usually means "No Language", so that might be the problem in your case. To make it streamlined, I am just using the selected text to tell us which language is applied, and change the double quotes for that language.
- Mark

