Article View: adobe.scripting.indesign
Article #573Re: Finding fontStyle error....
From: thiyagus5
Date: Mon, 16 Mar 2009 08:44
Date: Mon, 16 Mar 2009 08:44
42 lines
2563 bytes
2563 bytes
Hi robin,
Thanks for your kind support. Now the script works fine. I have one more concern in this script, i have find the superscript and subscript texts and replace it with created 'sup' & 'sub' character styles. But my script doesn't find the text of superscript & subscript. Find my full script here. Please check it and help me for this.
//To find Font style and replacing it with corresponding character styles
//Script for CS3
#target InDesign
var myDoc = app.activeDocument;
var Itl = myDoc.characterStyles.add({name: "Itl", fontStyle: "Italic"});
var sup = myDoc.characterStyles.add({name: "sup", position: Position.superscript});
var sub = myDoc.characterStyles.add({name: "sub", position: Position.subscript});
app.findTextPreferences.fontStyle = "Italic";
app.changeTextPreferences.appliedCharacterStyle = Itl;
app.documents.item(0).changeText();
app.findTextPreferences.findTextPosition = Position.superscript;
app.changeTextPreferences.appliedCharacterStyle = sup;
app.documents.item(0).changeText();
app.findTextPreferences.findTextPosition = Position.subscript;
app.changeTextPreferences.appliedCharacterStyle = sub;
app.documents.item(0).changeText();
function setupFindText(find, change, foots, hidLayers, lockedLayers, lockedStories, masters) {
app.findTextPreferences = null;
app.changeTextPreferences = null;
try { app.findTextPreferences.findWhat = find } catch(e) {};
try {app.changeTextPreferences.changeTo = change } catch(e) {};
app.findChangeTextOptions.properties = {
includeFootnotes:(foots == null ? false : foots),
includeHiddenLayers:(hidLayers == null ? false : hidLayers),
includeLockedLayersForFind:(lockedLayers == null ? false : lockedLayers),
includeLockedStoriesForFind:(lockedStories == null ? false : lockedStories),
includeMasterPages:(masters == null ? false : masters),
includeCaseSensitive:(caseSensitive == null ? false : caseSensitive)
}
}
Regards
Thiyagu
Technical Details
Message-ID:
<59b83590.1@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b83590.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,4780730dcf709f0d X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: thiyagus5@adobeforums.com Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Finding fontStyle error.... Message-ID: <59b83590.1@webcrossing.la2eafNXanI> Date: Mon, 16 Mar 2009 01:44:15 -0700 References: <59b83590.-1@webcrossing.la2eafNXanI> Lines: 54 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit