Replace selected text by another TextFrame content
Hi,
I'm trying to transform a selected text to something new, involving text displacement and paragraph styling using a jsx script. Right now, everything works great :
- I grab the select text
- I create a new temporary TextFrame
- I generate my new paragraphs and apply styles to them in the new TextFrame
What I wasn't able to achieve yet is to replace the original seleted text by the temporary TextFrame content.
Any help would be more than welcome ![]()
Some part of my script :
myText = app.selection[0].contents;
...do some stuff
var myDocument = app.documents.item(0);
var myPage = myDocument.pages.item(0);
var myTextFrame = myPage.textFrames.add();
myTextFrame.geometricBounds = [0, -70, 150, 70];
myTextFrame.contents = "Paragraph1\rParagraph2...";
myTextFrame.paragraphs[0].appliedParagraphStyle = pStyleGroup.paragraphStyles.itemByName('Style1');
myTextFrame.paragraphs[1].appliedParagraphStyle = pStyleGroup.paragraphStyles.itemByName('Style2');
And now, in myTextFrame, I have my formated new paragraph, and I'd like to replace the original selected text by my TextFrame content (keeping the paragraph styles).