Thread View: adobe.scripting.indesign
4 messages
4 total messages
Started by Chris_Van_Jones
Thu, 02 Apr 2009 16:39
Add Formatted Text
Author: Chris_Van_Jones
Date: Thu, 02 Apr 2009 16:39
Date: Thu, 02 Apr 2009 16:39
9 lines
998 bytes
998 bytes
Hello, I am trying to create a series of scripts to be used in a template that add/insert formatted text at a cursors location. So far, I have created the following script: app.selection[0].paragraphs[0].insertionPoints[0].contents = 'Voiceover' This works just fine, but how do I get this text to automatically select a Paragragh style I have defined. Thanks!
Re: Add Formatted Text
Author: Dave_Saunders
Date: Thu, 02 Apr 2009 16:48
Date: Thu, 02 Apr 2009 16:48
5 lines
732 bytes
732 bytes
app.selection[0].paragraphs[0].appliedParagraphStyle = myStyle; where myStyle is a reference to the paragraph style. Dave
Re: Add Formatted Text
Author: Chris_Van_Jones
Date: Thu, 02 Apr 2009 17:06
Date: Thu, 02 Apr 2009 17:06
8 lines
1153 bytes
1153 bytes
Excellent. I now have a follow-up question. How can I add a new line of text? For example, the above script writes "Voiceover" in BigRed paragraph style. Now I want to add a new line under "Voiceover" that says "Line 2" in a different paragraph style. This is what I have come up with: app.selection[0].paragraphs[0].insertionPoints[0].contents = 'Voiceover' app.selection[0].paragraphs[0].appliedParagraphStyle = 'BigRed' app.selection[0].paragraphs[0].insertionPoints[10].contents = 'Line 2' app.selection[0].paragraphs[0].appliedParagraphStyle = 'BigRed2' Thanks Again!
Re: Add Formatted Text
Author: Robert Tkaczyk
Date: Fri, 03 Apr 2009 00:52
Date: Fri, 03 Apr 2009 00:52
34 lines
2415 bytes
2415 bytes
add "\r" at end of your text contents or as a single character app.selection[0].paragraphs[0].insertionPoints[-1].contents = 'Voiceover\r' or app.selection[0].paragraphs[0].insertionPoints[-1].contents = '\r' if you are building new text in new empty Story or at end of current Story - don't use absolute index - .insertionPoints[10] - use .insertionPoints[-1] as reference to last item app.selection[0].paragraphs[-1].insertionPoints[-1].contents = '\r' (you need to add this line if you want to start new paragraph after existing text) app.selection[0].paragraphs[-1].appliedParagraphStyle = 'BigRed' app.selection[0].paragraphs[-1].insertionPoints[-1].contents = 'Voiceover\r' app.selection[0].paragraphs[-1].appliedParagraphStyle = 'BigRed2' app.selection[0].paragraphs[-1].insertionPoints[-1].contents = 'Line 2\r' like you can see - you need to switch order of lines - first you need to set formatting (ParaStyle) - then set new contents - and this is the best order of operations step 1 - set formatting to LastInsertionPoint step 2 - set contents of LastInsertionPoint thanks to this - you don't need to care how long will be your new text ;) if you want to add new text to empty TextFrame - you can't refer to first paragraph - because there is no paragraphs in empty TextFrame - you need to refer to insertionPoint - and better - to last insertionPoint of parentStory app.selection[0].parentStory.insertionPoints[-1] robin -- www.adobescripts.com
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