Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Looking for a Script to Delete empty Inline frames

New Here ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

Does anybody know of a script I could run in InDesign to remove empty inline frames from multiple text frames throughout my document?

Screen Shot 2019-04-10 at 10.28.22 AM.png

Screen Shot 2019-04-10 at 10.29.57 AM.png

These frames are present for variable data, but once the data is merged I'd like to remove the unused frames to ensure what is left is centered in the text frame.

In my initial search, I found this script to delete empty text frames (DeleteEmptyFrames.jsx), but I don't know enough to modify this to find and delete the empty graphics frames WITHIN text frames (if that is even possible)

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--)    {

        if (myTextFrames.contents == ""){

            myTextFrames.remove();

        }

    }

}

Thank you to anyone willing to help!

Views

710

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Apr 10, 2019 Apr 10, 2019
Try this:var myStories = app.activeDocument.stories.everyItem().getElements();  for (i = myStories.length - 1; i >= 0; i--){      var myPageItems = myStories.pageItems;      for (j = myPageItems.length - 1; j >= 0; j--)    {          var ag = myPageItems.allGraphics        if (ag == ""){              myPageItems.remove();          }      }  } 

Likes

Translate

Translate
Adobe Community Professional ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

Try this:

var myStories = app.activeDocument.stories.everyItem().getElements(); 

for (i = myStories.length - 1; i >= 0; i--){ 

    var myPageItems = myStories.pageItems; 

    for (j = myPageItems.length - 1; j >= 0; j--)    { 

        var ag = myPageItems.allGraphics

        if (ag == ""){ 

            myPageItems.remove(); 

        } 

    } 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2019 Apr 10, 2019

Copy link to clipboard

Copied

Heck yes! That worked a treat

Thank you so much!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 11, 2020 Feb 11, 2020

Copy link to clipboard

Copied

Hi,
There was a question in the script of the correct answer, so I modified it a little.

var myStories = app.activeDocument.stories.everyItem().getElements();  
for (i = myStories.length - 1; i >= 0; i--){  
    var myPageItems = myStories[i].pageItems;  
    for (j = myPageItems.length - 1; j >= 0; j--) {  
        if (myPageItems[j].allGraphics.length == 0){  
            myPageItems[j].remove();  
        }  
    }  
}  

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 26, 2019 Nov 26, 2019

Copy link to clipboard

Copied

Hello, thanks for script. I am trying this script, but it doesn't work. I am getting this error;Screen Shot 2019-11-26 at 23.49.23.png

Thank you for your help.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 11, 2020 Feb 11, 2020

Copy link to clipboard

Copied

Has an update broken this script? I am also getting the "undefined is not an object" error when trying to run this script.

EDIT: ajabon's code posted above now works perfectly. Thanks ajabon!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 12, 2020 Feb 12, 2020

Copy link to clipboard

Copied

Nicholas asked: Has an update broken this script?

Yes. This "update" was the introduction of the new forum software last year.

A lot of posted script code was damaged while moving threads over to the new forums.

 

Rely on the code thankfully posted by ajabon here:

https://community.adobe.com/t5/indesign/looking-for-a-script-to-delete-empty-inline-frames/m-p/10918...

 

FWIW: The code's issues are not the fault of the code poster.

It's just the fault of the ones who did the algorithm to move threads from the old Adobe forum software to the new Adobe forum software.

 

Regards,
Uwe Laubender

( ACP )

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 12, 2020 Feb 12, 2020

Copy link to clipboard

Copied

LATEST

Thanks Uwe! That worked perfectly!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines