Replace text (I'm getting error then replace text envelope) can someone help me

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[i]; 
         
           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; 
               } 
      } 
} 
}

Perhaps this snippet of script will help you a 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

Tags: Illustrator

Similar Questions

Maybe you are looking for

  • How to disable or clear the great screen?

    So the impressive screen is so great that the clearing of the history is not clear it! How can it be deleted? Only one I found so far is to delete the app and reinstall it.

  • Broken after repair screen

    Recently, after a message received on the laptop advise it be returned because of a problem with the fan, I sent my laptop to Toshiba UK, it was packed in the same packaging, he came and was in perfect condition when it was sent. Now, after days of w

  • HP Officejet Pro 8715: Scan to email does not work

    Hello I tried to set up the scan to e-mail function on my new printer with no luck. Currently, the printer can scan to my computer, but not e-mail. I have entered the following information on the built-in web server page: Default to: [email protected]

  • How to burn photos to a CD

    I'm taking pictures of bad shingles on my roof in the hope that I will get a refund of the roofing company and instead of actually taking pictures with have treated them, I thought that I would have them incorporated in a CD and he sent to them for t

  • Win 7 Home Pro update (automatic) August gave rise to BSOD

    Hello, after using my Pavilion G5470 for several years now running Windows 7 Home Pro, I was very surprised when I auto-installé the usual monthly updates/patches and all of a sudden, I can't start is more the system!  Fortunately, I can still make i