Copy link to clipboard
Copied
I want to change in my text frames written in paragraph style "EBT" text
Between 1 to 3 of "ABC" text
Between 4 and 7 "BIM" text
Between 7 and 10 "KLM" text
should write
where and how an error
var myDoc = app.activeDocument;
var myFrame = myDoc.allPageItems;
for(var i=0;i<myFrame.length;i++){
//if(myFrame.appliedObjectStyle == tmc) {
//if(i==5){break;}
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "myParS";
app.findGrepPreferences.findWhat = "EBT";
if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo = "ABC";}
if ((i > 3) && (i <= 7)) {var changeX = app.changeGrepPreferences.changeTo = "BIM";}
if ((i > 7) && (i <= 10)) {var changeX = app.changeGrepPreferences.changeTo = "KLM";}
myFrame.texts[0].changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
Dirty solution ... 😉
...var myDoc = app.activeDocument;
var myFrame = myDoc.allPageItems;
for(var i=0;i<myFrame.length;i++){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "myParS";
app.findGrepPreferences.findWhat = "EBT";
var j = parseInt(myFrame.texts[0].contents, 10); //****************** + ****************
if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo = "ABC"; myFrame.changeGrep(); }
if ((j
Copy link to clipboard
Copied
Hi,
1- it lacks a hook closure at the end "}"
2- you do not process myFrame[0] in your code, if this frame content "EBT", it will be erased
if ((i > 0) && (i <= 3)) {var changeX = app.changeGrepPreferences.changeTo = "ABC";}
Copy link to clipboard
Copied
there I noticed the error
all the "ABC" doing text
if the end of the "break continue" Did I need to add
Copy link to clipboard
Copied
Sorry but i don't understand your problem ...
Copy link to clipboard
Copied
the problem is to place the order
but I was able to solve a number of rotating post (parseInt)
var myDoc = app.activeDocument;
var myFrame = myDoc.allPageItems;
for(var i=0;i<myFrame.length;i++){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "myParS";
app.findGrepPreferences.findWhat = "EBT";
var j = parseInt(myFrame.texts[0].contents, 10); //****************** + ****************
if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo = "ABC";}
if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo = "BIM";}
if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo = "KLM";}
myFrame.changeGrep();
app.findGrepPreferences = app.changeGrepPreferences = null;
}
but to stop after 10 "break" command in the summer when the results fiasco
Copy link to clipboard
Copied
Have you a screen of your doc ?
Copy link to clipboard
Copied
11, and 12 don't change
before after

Copy link to clipboard
Copied
Dirty solution ... 😉
var myDoc = app.activeDocument;
var myFrame = myDoc.allPageItems;
for(var i=0;i<myFrame.length;i++){
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = "myParS";
app.findGrepPreferences.findWhat = "EBT";
var j = parseInt(myFrame.texts[0].contents, 10); //****************** + ****************
if ((j > 0) && (j <= 3)) {app.changeGrepPreferences.changeTo = "ABC"; myFrame.changeGrep(); }
if ((j > 3) && (j <= 7)) {app.changeGrepPreferences.changeTo = "BIM"; myFrame.changeGrep(); }
if ((j > 7) && (j <= 10)) {app.changeGrepPreferences.changeTo = "KLM"; myFrame.changeGrep(); }
app.findGrepPreferences = app.changeGrepPreferences = null;
}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more