Skip to main content
karthickm50893796
Inspiring
April 8, 2016
Answered

Text Replace ( i am getting error while replace Envelope Text ) Can anyone help me

  • April 8, 2016
  • 1 reply
  • 926 views

var active_doc = app.activeDocument;

var dlg = new Window('dialog', 'TEXT REPLACE');

    var gro =dlg.add('group');

    gro.orientation = 'row';

      

    var Orderno = gro.add('StaticText' ,{x:10,y:40,width:70,height:20});

    Orderno.text = 'TEXT :';

    var OrdernoValue = gro.add('EditText',{x:10,y:40,width:100,height:20},"");

    OrdernoValue.text   = OrdernoValue.value;

    

    var g_btn = dlg.add("group");

    var btn_ok = g_btn.add("button", undefined, "Ok");

    var btn_ccl = g_btn.add("button", undefined, "Cancel");

    btn_ok.onClick = function()

    {

        if(Orderno)

        {

            dlg.close();

        }

        else

        {

            return;

         }

     }

dlg.show();

replace(/TEXT/gi,OrdernoValue.text);

function replace(search_string,replace_string)

{

var text_frames = active_doc.textFrames;

if (text_frames.length > 0)

{

    for (var i = 0 ; i < text_frames.length; i++)

      {

          var this_text_frame = text_frames;

        

           var new_string = this_text_frame.contents.replace(search_string, replace_string);

           

           if (new_string != this_text_frame.contents)

               {

                    this_text_frame.contents = new_string;

               }

      }

}

}

This topic has been closed for replies.
Correct answer pixxxelschubser

Hi pixxxel schubser

Please find below test file

Test.zip - Google Drive

Thanks | Karthick M


Perhaps this script snippet helps you a little bit:

// select one envelope text

var sel = app.activeDocument.selection;

app.executeMenuCommand ('Release Envelope');

var sel2 = app.activeDocument.selection;

sel2[1].contents = (sel2[1].typename == "TextFrame") ? "NEW TEXT" : sel2[1].contents;

app.executeMenuCommand ('Make Envelope');

Have fun

1 reply

karthickm50893796
Inspiring
April 9, 2016

Can any one help solve above mention problem,

Actually normal text replace is working fine, but envelope text are not replace

pixxxelschubser
Community Expert
Community Expert
April 9, 2016

Sorry. but I don't know what exactly is "envelope Text" Do you have a good translation for german language? (The next thing which is similar is envelope distort)

Or can you upload and link an AI-file

with normal text which does

and with your envelope text.

karthickm50893796
Inspiring
April 11, 2016

Hi pixxxel schubser

Please find below test file

Test.zip - Google Drive

Thanks | Karthick M