Change Specific Paragraph Style to Nothing and Delete All Empty Frames
Hi Experts,
I have a problem, i'm trying to simulate the situation of using find/change like this :

So if i use the Above method it will find the Paragraph Style (Numbering) and Delete All Text inside its frames, this is good trick to get rid of all text applied (paragraph styles) then i use the following code to delete all empty frames :
//Delete All Empty Text Frames
var myStories = app.activeDocument.stories.everyItem().getElements();
for (i = myStories.length - 1; i >= 0; i--){
var myTextFrames = myStories[i].textContainers;
for (j = myTextFrames.length - 1; j >= 0; j--) {
if (myTextFrames[j].contents == ""){
myTextFrames[j].remove();
}
}
}but what i need to do is to Simulate all the Process with only JavaScript, so it will to get rid from all the text and frames with one hit, here is my try :
//Change Paragraph Styles from Desired to Nothing and Delete Empty Frames
var allPars = app.activeDocument.textFrames.everyItem().paragraphs.everyItem().getElements();
alert(allPars.length);
for (var i = 0; i < allPars.length; i++) {
if (allPars[i].appliedParagraphStyle.name == "Numbering") {
allPars[i].appliedParagraphStyle = "";
}
}
//Delete All Empty Text Frames
var myStories = app.activeDocument.stories.everyItem().getElements();
for (i = myStories.length - 1; i >= 0; i--){
var myTextFrames = myStories[i].textContainers;
for (j = myTextFrames.length - 1; j >= 0; j--) {
if (myTextFrames[j].contents == ""){
myTextFrames[j].remove();
}
}
}but i get ther error code : 30477

so please help if this can be done ?
Thanks in Advance
Best Regards
M.Hasanain
