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

How do I delete all text frames using javascript

Engaged ,
Apr 20, 2017 Apr 20, 2017

Copy link to clipboard

Copied

I trying to set up code at the beginning of my script that will look and see if there is a text frame in the document (it will have text in it but I'm not sure if its relevant), and if it exists delete it.

Does anyone have an idea if this can be done?

Thanks,

~David

TOPICS
Scripting

Views

2.3K

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

LEGEND , Apr 20, 2017 Apr 20, 2017

app.activeDocument.textFrames.everyItem().remove();

(^/)

Votes

Translate

Translate
Engaged ,
Apr 20, 2017 Apr 20, 2017

Copy link to clipboard

Copied

Hi,

Try this code.

var myDoc = app.activeDocument;

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

            myTextFrames.remove();  

            }  

        } 

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.

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
LEGEND ,
Apr 20, 2017 Apr 20, 2017

Copy link to clipboard

Copied

app.activeDocument.textFrames.everyItem().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
Engaged ,
Apr 20, 2017 Apr 20, 2017

Copy link to clipboard

Copied

LATEST

These both worked well, 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