extendscript - How to replace selected text in InDesign via script? -


in scripted ui panel, have button supposed insert text. came routine, which, indeed, inserts whatever text wherever want, if there text selected, doesn't replace selection.

how can modify function replace selection? if there nothing selected, should insert text normally.

function inserttext(whattext){     if( app.selection.length < 1 ){ exit(); }     var tf = app.selection;     for( var q = 0; q < tf.length; q++ ){         var thisframe = tf[q];         var originaltext = thisframe.contents;         thisframe.contents = originaltext + whattext;     } } 

hmmm... well, seems work pretty well... [embarassed on face]

function inserttext(whattext){ app.selection[0].contents = whattext; }


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -