Thread View: adobe.scripting.indesign
7 messages
7 total messages
Started by Andrew_Alcantara
Mon, 26 Jan 2009 14:06
[AS][CS3] Finding text with character style
Author: Andrew_Alcantara
Date: Mon, 26 Jan 2009 14:06
Date: Mon, 26 Jan 2009 14:06
7 lines
823 bytes
823 bytes
Please help to tell me how to find text with a specific character style and then delete the text. I had no problem doing this with CS2 but its doing my head in now. Thanks, Andrew
Re: [AS][CS3] Finding text with character style
Author: Dave_Saunders
Date: Mon, 26 Jan 2009 14:24
Date: Mon, 26 Jan 2009 14:24
33 lines
2172 bytes
2172 bytes
Here you go. This assumes that your character style is at the top level of the panel. If you're using style groups, you'll need to write code to get at the style you want to use.
//DESCRIPTION: Delete text in named character style
(function() {
if (app.documents.length > 0) {
deleteStyledText(app.documents[0]);
}
function deleteStyledText(aDoc) {
var cStyle = aDoc.characterStyles.item("CharStyleName");
setupFindText();
app.findTextPreferences.appliedCharacterStyle = cStyle;
aDoc.changeText();
}
function setupFindText(find, change, wholeWd, caseSense, 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 = {
caseSensitive:(caseSense == null ? false : caseSense),
wholeWord:(wholeWd == null ? false : wholeWd),
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)
}
} // end setupFindText
}())
Dave
Re: [AS][CS3] Finding text with character style
Author: Shane_Stanley
Date: Mon, 26 Jan 2009 21:44
Date: Mon, 26 Jan 2009 21:44
14 lines
1626 bytes
1626 bytes
You could try this:
tell application "Adobe InDesign CS3"
tell document 1
set thestyle to character style "Whatever"
delete (every text style range of every story whose applied
character style is thestyle)
end tell
end tell
--
Shane Stanley <sstanley@myriad-com.com.au>
AppleScript Pro Florida, April 2009 <http://scriptingmatters.com/aspro>
Re: [AS][CS3] Finding text with character style
Author: Dave_Saunders
Date: Mon, 26 Jan 2009 22:40
Date: Mon, 26 Jan 2009 22:40
3 lines
680 bytes
680 bytes
Ah, I failed to spot the AS in the topic. Dave
Re: [AS][CS3] Finding text with character style
Author: Andrew_Alcantara
Date: Tue, 27 Jan 2009 09:18
Date: Tue, 27 Jan 2009 09:18
8 lines
885 bytes
885 bytes
Thank you to the both of you. However this is still giving me error "CS3 got an error. Can't set character style of find text preferences to character style ID of document" I have tried changing things around but still get the same error. Appreciate your help, Regards, Andrew
Re: [AS][CS3] Finding text with character style
Author: Shane_Stanley
Date: Tue, 27 Jan 2009 10:20
Date: Tue, 27 Jan 2009 10:20
8 lines
1582 bytes
1582 bytes
If you want to do the search using the find/change commands, you need to make a temporary character style of the same name at the application, use a reference to that style for the search, and then delete it from the app when you're finished. -- Shane Stanley <sstanley@myriad-com.com.au> AppleScript Pro Florida, April 2009 <http://scriptingmatters.com/aspro>
Re: [AS][CS3] Finding text with character style
Author: Andrew_Alcantara
Date: Tue, 27 Jan 2009 15:09
Date: Tue, 27 Jan 2009 15:09
5 lines
664 bytes
664 bytes
Thanks for your help, it is all working now. Regards, Andrew
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