Thread View: adobe.scripting.indesign
5 messages
5 total messages
Started by thiyagus5
Sat, 14 Mar 2009 13:50
Finding fontStyle error....
Author: thiyagus5
Date: Sat, 14 Mar 2009 13:50
Date: Sat, 14 Mar 2009 13:50
19 lines
1207 bytes
1207 bytes
Hi everyone,
I am just finding the font style "Italic" which is applied in the document. And replace it with newly created character style named "myCstyle". While running the script the character style is created but it shows some errors in finding. Find my CS3 MAC script below,
//----------
//Creating character style for applied font styles...
var myDoc = app.activeDocument;
var myCstyle = myDoc.characterStyles.add({name: Itl, fontStyle: "Italic"})
app.findTextPreferences.findWhat = app.appliedFontStyle("Italic");
app.changeTextPreferences.changeTo = myCstyle;
//-----------
Please look into and help me for this. Thanks in advance
Regards
Thiyagu
Re: Finding fontStyle error....
Author: Robert Tkaczyk
Date: Sat, 14 Mar 2009 14:05
Date: Sat, 14 Mar 2009 14:05
33 lines
1890 bytes
1890 bytes
From VB ObjectBrowser:
Property FindWhat As Variant
Member of InDesign.FindTextPreference
The FindTextPreference to find. as String or idNothingEnum enumerator
Property ChangeTo As Variant
Member of InDesign.ChangeTextPreference
The replacement ChangeTextPreference. as String or idNothingEnum enumerator
so you can't apply FontStyle and CharStyle to Properties awaiting for String type
You need to set formatting you looking for to fontStyle and appliedCharacterStyle
Property FontStyle As Variant
Member of InDesign.FindTextPreference
The name of the font style. as String or idNothingEnum enumerator
Property AppliedCharacterStyle As Variant
Member of InDesign.ChangeTextPreference
The character style to search for or change to. as String, CharacterStyle or idNothingEnum enumerator
There is no "appliedFontStyle" in VB so I'm not sure if it will be in JS ...
here is example in VB:
myInDi.FindTextFreferences.FontStyle = "Italic"
myInDi.ChangeTextPreferences.AppliedCharacterStyle = myDoc.CharacterStyles.Item("Italic")
robin
--
www.adobescripts.com
Re: Finding fontStyle error....
Author: 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
Re: Finding fontStyle error....
Author: jongware
Date: Mon, 16 Mar 2009 10:14
Date: Mon, 16 Mar 2009 10:14
3 lines
758 bytes
758 bytes
The fontStyle is still set to 'italic'. You might want to start by setting all findTextPreferences to nothing, because it will continue with what was set the last time you searched.
Re: Finding fontStyle error....
Author: thiyagus5
Date: Tue, 17 Mar 2009 05:04
Date: Tue, 17 Mar 2009 05:04
6 lines
726 bytes
726 bytes
Hi jongware, Wow! its working fine. What you said is exactly right. Thanks for your kind help. Have a nice day. Regards Thiyagu
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads