Find and Remove Empty Frames after Data Merge
I know this has come up multiple times. I have read through all the threads, and tried many of the scripts that people have written code for. Some work partially, some Give me error 21 and cant finish - so maybe they work, But i cannot seem to find a script that will delete Empty frames after a data merge, that also Deletes Frames which are EMPTY BUT have a Paragraph Symbol & Figure Space left.
I have tried a Script that David Blatner posted in 2018 on Creative Pro,
I have tried a script UWE posted back in 2013 that has some updates listed to it. I have tried 4 others labeled "RemoveEmptyFrame", "EmptyFrameRemover", "DeleteEmptyFrames", and "by_LFC Remove Empty Frame". I have found a post on a website which links to a script but it gives me a 404 error, so i have not tried that one. I also found one posted on "Colecandoo" for a "updated-empty-frame-remover-1-1" but his link is broken as it takes you to the Adobe community forum homepage instaed of to the thread that was written (The website blogger is also a contributer on creativepro)
I most recently tried this code, but i get an error on Line 19: Would anyone be able to help on a solution for me? i havent seen any updates on this specific request since 2019.
var myDocument = app.activeDocument;
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "<FEFF>";
app.changeTextPreferences.changeTo = "";
myDocument.changeText();
app.findTextPreferences = app.changeTextPreferences = null;
var myStories = app.activeDocument.stories.everyItem().getElements();
for (i = myStories.length - 1; i >= 0; i--){
var myTextFrames = myStories.textContainers;
for (j = myTextFrames.length - 1; j >= 0; j--) {
var stroke = myTextFrames.strokeWeight;
var color = myTextFrames.fillColor.name;
var wrap = myTextFrames.textWrapPreferences.textWrapMode;
//alert (color)
if (myTextFrames.contents == "" && stroke == "0" && color == "None" && wrap === TextWrapModes.NONE){
//alert ("yes")
myTextFrames.remove();
}
}
}
var _d = app.documents[0],
_allStories = _d.stories;
for (var n = _allStories.length - 1; n >= 0; n--){
var _storyAllTextFrames = _allStories.textContainers;
for (var m = _storyAllTextFrames.length - 1; m >= 0; m--){
if (_storyAllTextFrames.contents === "")
try{
_storyAllTextFrames.contentType = ContentType.UNASSIGNED;
}catch(e){};
}
}
var myGraphicFrames = app.activeDocument.rectangles;
for (i=myGraphicFrames.length-1; i>=0; i--) {
var stroke = myGraphicFrames.strokeWeight;
var color = myGraphicFrames.fillColor.name;
var wrap = myGraphicFrames.textWrapPreferences.textWrapMode;
if (myGraphicFrames.graphics.length < 1 && stroke == "0" && color == "None" && wrap === TextWrapModes.NONE)
myGraphicFrames.remove();
}
var myOvalFrames = app.activeDocument.ovals;
for (i=myOvalFrames.length-1; i>=0; i--) {
var stroke = myOvalFrames.strokeWeight;
var color = myOvalFrames.fillColor.name;
var wrap = myOvalFrames.textWrapPreferences.textWrapMode;
if (myOvalFrames.graphics.length < 1 && stroke == "0" && color == "None" && wrap === TextWrapModes.NONE)
myOvalFrames.remove();
}
var myPolygonFrames = app.activeDocument.polygons;
for (i=myPolygonFrames.length-1; i>=0; i--) {
var stroke = myPolygonFrames.strokeWeight;
var color = myPolygonFrames.fillColor.name;
var wrap = myPolygonFrames.textWrapPreferences.textWrapMode;
if (myPolygonFrames.graphics.length < 1 && stroke == "0" && color == "None" && wrap === TextWrapModes.NONE)
myPolygonFrames.remove();
}