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

How do I delete all text frames using javascript

Engaged ,
Apr 20, 2017 Apr 20, 2017

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
2.5K
Translate
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();

(^/)

Translate
Engaged ,
Apr 20, 2017 Apr 20, 2017

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.
Translate
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

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

(^/)

Translate
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
LATEST

These both worked well, thank you so much!

Translate
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