Thread View: adobe.scripting.indesign
6 messages
6 total messages
Started by Rick_Quatro
Tue, 20 Jan 2009 21:09
[CS3 JS] Replace text in a paragraph
Author: Rick_Quatro
Date: Tue, 20 Jan 2009 21:09
Date: Tue, 20 Jan 2009 21:09
3 lines
716 bytes
716 bytes
I want to replace all of the text in a paragraph, without removing the \r at the end of the paragraph. What is the best method for doing that? Thank you very much. Rick Quatro
Re: [CS3 JS] Replace text in a paragraph
Author: Olav_Kvern
Date: Tue, 20 Jan 2009 21:20
Date: Tue, 20 Jan 2009 21:20
12 lines
801 bytes
801 bytes
Hi Rick, Use itemByRange(): //Where myParagraph is a paragraph... myParagraph.texts.itemByRange(myParagraph.characters.item(0), myParagraph.characters.item(-2)).remove(); Thanks, Ole
Re: [CS3 JS] Replace text in a paragraph
Author: Peter Kahrel
Date: Tue, 20 Jan 2009 23:06
Date: Tue, 20 Jan 2009 23:06
8 lines
696 bytes
696 bytes
Or maybe just
myParagraph.contents = '\r';
Peter
Re: [CS3 JS] Replace text in a paragraph
Author: Olav_Kvern
Date: Tue, 20 Jan 2009 23:13
Date: Tue, 20 Jan 2009 23:13
7 lines
759 bytes
759 bytes
Hi Peter, The trouble with that approach, though, is that you run the risk of changing the style applied to the paragraph. Thanks, Ole
Re: [CS3 JS] Replace text in a paragraph
Author: Rick_Quatro
Date: Wed, 21 Jan 2009 00:08
Date: Wed, 21 Jan 2009 00:08
7 lines
819 bytes
819 bytes
Thanks to Ole and Peter. Yes, I need to maintain the style that is applied to the paragraph. Also, I added this test in case the paragraph is empty already.
if (myParagraph.characters.length > 1) {
...
}
Rick
Re: [CS3 JS] Replace text in a paragraph
Author: Peter Kahrel
Date: Wed, 21 Jan 2009 00:49
Date: Wed, 21 Jan 2009 00:49
10 lines
852 bytes
852 bytes
The trouble with that approach, though, ...
Aha... hadn't realised that. In fact, it turns out that it changes the paragraph style applied to the next paragraph to that of paragraph whose contents is deleted. Didn't know that.
Peter
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