• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.2K

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

Community Expert , 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(); 

        } 

    } 

Votes

Translate

Translate
Community Expert ,
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(); 

        } 

    } 

Votes

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!

Votes

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
Community Expert ,
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();  
        }  
    }  
}  

Votes

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.

Votes

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!

Votes

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
Community Expert ,
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 )

 

 

Votes

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!

Votes

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