Replace the selected text with other content TextFrame

Hello

I am changing a text selected in something new, involving the movement of text and the paragraph style using a jsx script. At the present time, everything works beautifully:

  • I entered the select text
  • I have create a new temporary TextFrame
  • I build my new paragraphs and apply styles to them in the new TextFrame

What I was not able to reach still is to replace the original selected text by temporary TextFrame content.

Any help would be more than welcome

A 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 new paragraph formatted, and I would like to replace the original selected text with the contents of my TextFrame (keeping the paragraph styles).

Hello

Keep the logic of the code and edit utilities:

var
    mSourceIdx = app.selection[0].index,
    mStory = app.selection[0].parentStory,
    mReplaceStuff = {
        elements: [
            ["Paragraph_1\r",  "Style_1"],
            ["Paragraph_2\r",  "Style_2"],
            ["Paragraph_X\r",  "Style_X"]
            ]},
    mTarget, cElement, cText, cParaStyle;

while (cElement = mReplaceStuff.elements.pop()) {
    cText = cElement[0];
    cParaStyle = app.activeDocument.paragraphStyles.item(cElement[1]);    // modify if styleGroups present in a structure
  mTarget = mStory.insertionPoints.item(mSourceIdx);
    mTarget.contents = cText;
    mTarget.paragraphs[0].appliedParagraphStyle = cParaStyle;
     }

app.selection[0].contents = "";

MReplaceStuff allows to prepare stuff to replace

Jarek

Tags: InDesign

Similar Questions

  • How to search the selected text with a default search engine?

    Hello

    Before the recent update of the search bar, you can select your 'current' search engine, and a search for the selected text (right click on the selection) would use this engine.

    Now, it seems that you can only search for the selected text using the default engine. If that is correct, it's a big step backwards for me. For example, I can't have Google as my default search engine and the search for a text selected on eBay!

    Or am I missing something?

    Thank you!

    R.

    I find this extension very useful for selected items in the web pages. It offers all your search engines with select > right click.
    https://addons.Mozilla.org/en-us/Firefox/addon/context-search/?src=search

  • CS6: create a simple extension: how to copy the selected text in the extension?

    Hello

    with this tutorial http://www.DWfaq.com/Tutorials/Extensions/simple_object.asp

    I created a very simple extensions in Dreamweaver CS6.

    But I can't find out how to get the code/selected text "in" this extension.

    I want to reformat the selection with the javascript code for the extension and replace the selected text.

    Thank you!

    mtemp

    Thank you very much for your answer!

    I didn't know the difference between these two methods - my google search for 'extension' led me directly to the old tutorial mentioned...

    And, Yes, I had to search long enough to find the 'object' extension on the fly on the menu...

    Now, I adapted the code referred to in the dreamweaver_cs5_extending.pdf for the creation of such an extension of command - and, wow, it works... with 'copy' the text selected in the extension form.

    So, thanks again! Now I'm on the right track

  • I downloaded red CS6 plugin and added to the contents of the package, replaced the existing files with the new without saving, now my thumbnails images RED and the color correction do not WORK! How to bring back my old file importerRed! ?? Help!

    I downloaded red CS6 plugin and added to the contents of the package, replaced the existing files with the new without saving, now my thumbnails images RED and the color correction do not WORK! How to bring back my old file importerRed! ?? Help!

    Try asking in the forum Premiere Pro seems to be an Adobe first Pro Lab

  • I have the network wireless with an extreme airport using my base station that dessert 4 Airport expresses. I want to replace the base station with a time capsule from apple.  Are there specific instructions other that connect the new time capsule

    I have a wired to the internet using my base station for 4 expresses the hard extreme airport.  I want to replace the base station with a time capsule.

    It is also easy to replace the existing base station and adding the name of the network and the password?

    You should be able to transfer your configuration of your current access point to new, and then you would just set up the internal drive, try to look at these articles:

    ith-new http://www.TechRepublic.com/article/apples-Airport-extreme-out-with-the-old-in-w.

    -one-airport-extreme-or-time-capsule-to-http://www.iclarified.com/31189/How-to-Transfer-Your-configuration-settings-fromanother

  • Acrobat 9 Pro: cannot copy the selected text unless I have a highlighting of the text

    I highlighted the text in a document. When I go to copy this text, it selects the whole sentence. I right click, the menu starts with "set status. There is no option "copy". No control-C is successful. When I paste then, he pastes a previously selected text, not the text I'm trying to copy in Acrobat. The only way I found to copy the selected text to the United Nations is a development and then copy it. Are there other solutions?

    Thank you!

    Play with the Shift key... you will get it.

  • Is it possible to replace the hard drive with an SSD? or would it be too expensive?

    Is it possible to replace the hard drive with an SSD?

    or would it be too expensive?

    Yes.  There are several alternatives.  I found a way relatively inexpensive, using a map of mSATA (very small SSD) and an adapter to connect it to the connector IDE 44 pin internal of my PowerBook.  It works very well.  Rather than repeat what I posted previously, you can watch these two topics (which also has good info, other users)

    Re: This win to install a SSD drive in a PowerBook G4?

    Re: SSDS  (my post is halfway - "this is how I did with my trusty Pismo...) »)

    FYI - I have used the adapter is even cheaper now

    https://www.Amazon.com/GP/product/B009BA8V4M

  • Retrieve the selected text

    Hello

    I just know how I can retrieve the text selected via the Menu:

    I add a MenuItem to the category system so that it is available everywhere:

    ... ApplicationMenuItemRepository.getInstance().addMenuItem(ApplicationMenuItemRepository.MENUITEM_SYSTEM,this);...
    

    Then after that I selected the text in the browser for example, I click on the Menu button:

    public Object run(Object context) {
      if ( context instanceof ) {
        //do something with the selected Text    ...
      }
    }
    

    It should allow me to do something with the text I've selected. What instance is that the text of selected?

    Can someone help me here?

    Thank you in advance!

            if (fld.isSelectionCopyable()){
                Clipboard cd = Clipboard.getClipboard();
                fld.selectionCopy(cd);
                Object s3 = cd.get();
            //(....)
    

    On the second reading of your code, you do not use the Clipboard correctly. Try the above.

  • Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Hello

    2796614 wrote:

    Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?

    Of course, it is possible.  According to what the text file looks like to, you can create an external table that treats the text file as if it were a table.  Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.

    You have problems whatever you wantt?  If so, your zip code and explain what the problem is.

    Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas.  In this case, also post a small sample of the text involved file.

    If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: Re: 2. How can I ask a question on the forums?

  • Cannot get the "< FEFF >" string in the selected text [indesign CS6]

    Hello world!

    I can't get the string to the selected text. The selected text contains several xml tags.

    In adobe indesign cc version of 2014, the selected text is bring the string «< FEFF >» tags

    In indesign adobe cs6 version cannot get the string "< FEFF >. they do ""-empty space.

    Screen Shot 2015-09-23 at 6.01.25 PM.png

    Are the above-selected text contains several xml tags.

    but I get content using script code can't get the string.

    Screen Shot 2015-09-23 at 6.02.51 PM.png

    the script gives the result, xml tags are converted to "". ""  I expect "< FEFF >.

    I expect the output is: "< FEFF > Applescript < FEFF > < FEFF > selected text < FEFF > < FEFF > < FEFF >."

    Please help me...

    Thank you

    John Peter.

    the script gives the result, xml tags are converted to "". ""  I expect to ''.

    The xml tags are not converted to "" but "\uFEFF" (zero-width space non-bec), it is the character used to represent the tags in a text frame. Looks like the apple script converts a hexadecimal representation unicode values.

  • Dreamweaver CC: How to change the color of the selected text

    Maybe a stupid question, but I can't seem to figure it out, even with searches on the web.  I want to change the color of a single word in my HTML document.  Can anyone offer advice?

    I can change some styles of the selected text (bold, italic, etc.), but do not understand the color.

    Also, I know how to change the color of the different elements using CSS.  But for the selected text in an element, CSS here the simplest solution?

    Thanks in advance.

    carlg79335635 wrote:

    Thank you for that.  But I don't have a color option in my menu format.  It ends at some CSS Styles.  I have to allow him anywhere?  I use Dreamweaver CC.

    Yes.  I checked it and in CC DW, there is not a way to do as I suggested previously.  I was watching DW CS6 and he got it.

    Looks like you'll need to teach how them to manually code.  This will make them think about what they are doing and so concentrate better.

  • Is it possible to convert the selected text in javascript lines?

    Hi all

    I put a word to indesign cs 5.5 file is almost in a single table, I need to separate the text of the actual tables, is it possible to convert the selected text in javascript lines?

    If there is no way to do that, someone can help me to make a script to cut selected lines and place it in the right holders of the table pointer to make independent table and then convert to text?

    Hey brother,

    Simply select the rows or cells represent the lines and then run this Javascript code snippet:

    for (var r = 0; r < app.selection.length; r++) {
        for (var t = 0; t < app.selection[r].rows.length; t++) {
            for (var u = 0; u < app.selection[r].rows[t].cells.length; u++) {
                for (var c = 0; c < app.selection[r].rows[t].cells[u].paragraphs.length; c++) {
                    app.selection[r].rows[t].cells[u].paragraphs[0].move (LocationOptions.AFTER, app.selection[r].rows[t].parent.parent.storyOffset);
                    if (c < app.selection[r].rows[t].cells[u].paragraphs.length - 1)
                        app.selection[r].rows[t].parent.parent.storyOffset.contents += "\r";
                }
                if (u < app.selection[r].rows[t].cells.length - 1) {
                    app.selection[r].rows[t].parent.parent.storyOffset.contents += "\t";
                }
                else {
                    app.selection[r].rows[t].parent.parent.storyOffset.contents += "\r";
                }
            }
        }
    }
    for (var r = 0; r < app.selection.length; r++) {
        for (var t = app.selection[r].rows.length - 1; t >= 0; t--) {
            app.selection[r].rows[t].remove ();
        }
    }
    
  • Adjust alignment (spacing) of the selected text

    I'm looking for a script that will allow me to apply a tracking value specific to the selected text in InDesign. I'm still not a fan in the script.

    I found the following script in the referenced article: Script: adjust the text alignment (spacing)

    /*

    < javascriptresource >

    < name > character followed... < / name >

    < enableinfo > true < / enableinfo >

    < menu > automate < / menu >

    < about > adjust the kerning. < / about us >

    < category > typography < / category >

    < / javascriptresource >

    */

    If (app.documents.length > 0) {}

    var targettext = app.activeDocument.activeLayer.textItem;

    targettext. Tracking = parseInt (command prompt ("select the letter spacing value", 0));

    }

    It looks like that's about what I would do. Two problems, I think that it is only designed for Photoshop (?), and second, I want to use for only selected text, not the whole page. Also, I want to apply the script to a keyboard shortcut (I guess it's possible).

    Can someone help with this? Sorry to ask, but I have a big document of two columns with a large amount of follow-up to and looking for shortcuts to clicking or typing in the track drop-down list box.


    Thank you very much!

    For InDesign?

    Why you need a script? It is always built in and works with the selected text!

    Using InDesign | Default keyboard shortcuts

    Have fun

  • A side navigation moves to the bottom of all other content on the site online

    This page is what looks like the NAV on the right at the bottom of the page:

    http://healthdimensionsgroup.com/our_team_administrators.html

    This is how it should look with the side right nav side with other content:

    http://healthdimensionsgroup.com/our_team_marketing.html

    Thought it might have something to do with the width of the table, but making it smaller doesn't seem to do anything. In dreamweaver, it seems to be in the right place, but when he put on the live site, it moves down. See below...

    Capture.PNG

    Open the style.css

    find the rule of #content_col_left_wide

    Change the width to 685 or less and

    SAVE IT and upload it to your CSS On YOUR REMOTE SERVER folder


  • apply the gradient to the selected text does not work

    with cs5, I click with the button straight on a text layer and choose select pixels and want to add a gradient to the selected text, but it says I need to rasterize the text first of all when I try to do it with the gradient tool? I thought you could do it without pixelation of text?

    Thanks for any clarification.

    Use a gradient overlay layer style or a gradient fill, cut on the text layer layer.

    Create a gradient layer style:

    http://help.Adobe.com/en_US/Photoshop/CS/using/WS76DA9F39-FFFA-4f3c-AC89-89FD52A84C02a.htm l

    Create a gradient fill layer:

    http://help.Adobe.com/en_US/Photoshop/CS/using/WS5A7BAC5F-EF4C-4fd1-94BB-6ACA59C8E73Fa.htm l #WS375F6CCC-1383-4729-A1CD-4D26F1C867DDa

    Clipped layer:

    http://help.Adobe.com/en_US/Photoshop/CS/using/WSfd1234e1c4b69f30ea53e41001031ab64-7853a.h tml

Maybe you are looking for