Removing empty text frames

trying to remove any text frames with empty content but it doesn't seem to be removing correct textFrame layers, any idea what I might be doing wrong?
var numberOfEmptyTextBoxes = 0;
var layersWithNoText = new Array();
if ( app.documents.length > 0 ) {
    for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) {
        text = app.activeDocument.textFrames[i].textRange;
        numWords = app.activeDocument.textFrames[i].words.length;
        if (numWords == 0){
                  layersWithNoText.push(i);
            numberOfEmptyTextBoxes++;
    if(numberOfEmptyTextBoxes > 0){
              alert("WARNING you have " + numberOfEmptyTextBoxes + " empty text boxes");
    alert("layers with no text:" +layersWithNoText);
    removeTextLayersWithNoContent(layersWithNoText);
function removeTextLayersWithNoContent(layersWithNoText) {
          var layersWithNoText = layersWithNoText;
          for (var i = 0; i < layersWithNoText.length; i++) {
                    var currentIndex = layersWithNoText[i];
                    alert("current index: "+currentIndex)
                    app.activeDocument.textFrames[currentIndex].remove();

yes, to do it like that, you would have to loop backwards to remove the textframes and not mess up with the indexes,
or, push the textframes into your array like this
var numberOfEmptyTextBoxes = 0;
var layersWithNoText = new Array();
if ( app.documents.length > 0 ) {
    for ( i = 0; i < app.activeDocument.textFrames.length; i++ ) {
        text = app.activeDocument.textFrames[i].textRange;
        numWords = app.activeDocument.textFrames[i].words.length;
        if (numWords == 0){
                  //layersWithNoText.push(i); // don't push the indexes
                  layersWithNoText.push(app.activeDocument.textFrames[i]); // push the actual text frames
            numberOfEmptyTextBoxes++;
    if(numberOfEmptyTextBoxes > 0){
              alert("WARNING you have " + numberOfEmptyTextBoxes + " empty text boxes");
    alert("layers with no text:" +layersWithNoText);
    removeTextLayersWithNoContent(layersWithNoText);
function removeTextLayersWithNoContent(layersWithNoText) {
          var layersWithNoText = layersWithNoText;
          for (var i = 0; i < layersWithNoText.length; i++) {
                    var currentIndex = layersWithNoText[i];
                    alert("current index: "+currentIndex)
                    //app.activeDocument.textFrames[currentIndex].remove(); // removing 1 item re-indexes the remaining items
                    layersWithNoText[i].remove(); // remove the textframes in the array, regardless of actual index

Similar Messages

  • CS3/4, JS Amateur question: how remove all empty text frames?

    I'm an amateur, and thought it would be a straightforward matter to write a script that simply deletes all empty text frames in all of a document's stories. Here's my second attempt:
    var myDocument = app.activeDocument;
    var myStories = myDocument.stories;
    for (i = 0; i < myStories.length; i++){
      var myStory = myStories[i];
      var myTextFrames = myStory.textContainers;
        for (j = myTextFrames.length - 1; j >=0; j--) {
        if (myTextFrames[j].contents == "") myTextFrames[j].remove();
    The trouble is, sometimes it works as intended, but sometimes, with multiple stories, it needs to be run more than once. Can anyone explain why that is?
    Thanks -- Jeremy

    [Jongware] wrote:
    (Bit of a Johnny-come-lately, but anyway )
    AHA! -- This is a great help. It was driving me up the wall, and I don't know why it didn't work for me last night. Maybe it's because I was counting through stories in the wrong direction. Anyhow, I see how it works now, and I'm very grateful for the help.
    By the way Harbs, I used all three of your suggestions because I had spent far too much time tapping away at that nut with my little toy hammer. I vented my frustration by using all three of your sledgehammers. In particular, I made sure it left a single empty text frame where it was, as such a frame might be used as a graphic. (Although in the past, I've found an empty story can be a sneaky place for a rogue font to hide. The insertion point just in front of the "end of story" character can have a paragraph style applied, with its associated font, but "Find" won't find any characters with that paragraph style or font applied!)
    Thanks to all again -- Jeremy

  • Starting Empty Text Frame

    I've always wondered what this empty text frame is when I start a new article. Usually I lock it and add my content above it. (Sorry if this is a total newbie question!)
    Thanks!

    Primary text frame:

  • Remove empty object frame

    How to remove empty object frame.(rectangle without image)

    I try the below code but it delete tables inside rectangle. i tried in javascript.
    var doc = app.activeDocument;
    var myPages = app.activeDocument.pages;
        for (var p = 0; p < myPages.length; p++)
                             var myGraphicFrames = app.activeDocument.pages[p].rectangles;
                             for (j = myGraphicFrames.length - 1; j >= 0; j--)
                                       if (myGraphicFrames[j].graphics.length == 0)
                                                 app.selection = myGraphicFrames[j];
                                                 alert (app.activeWindow.activePage.name);

  • Illustrator CS5 - removing empty text boxes

    I've always found it difficult to select the type I want when I'm using the type tool to edit some text. I can click directly over the type but I guess I'm a zillionth of a pixel off because about half the time it assumes I want to make a new text box. So my documents are littered with invisible empty type boxes that often get grouped with other objects, causing lots of problems. I'd love to know:
    1. How to make it easier to select type.
    2. How to delete all empty text boxes. I remember hearing of a built-in way to do this, which indicates Adobe knows it's a problem, but rather than making type selections easier, they give us a shortcut to undo the problem they caused. At any rate, I've forgotten the shortcut.
    Thanks for any help,
    Dave

    Kurt,
    If I took a glass of wine and savored it every time I realized 
    Illustrator doesn't behave as elegantly as FreeHand I would quickly 
    expire from cirrhosis.
    But I raise a glass to the forum users who know the ins and outs and 
    share them with the rest of us.
    Thanks,
    Dave

  • Removing text frames from rdf export format

    After a report has been exported in rdf format, can anyone tell me if there is a way to remove the text frames from the document, so that the formating is retained but by using word's tabs etc.
    Our client needs to manually add sections to the document after the report has been generated and we find that because of the text frames the document formatting gets ruined when new sections are added to the file.

    I don't know whether any of this will help?
    According to the manual there are only a very limited range of adjustments you can make to iMovie projects.
    Turn iMovie adjustments on or off
    When editing a project in iMovie, you can adjust several video attributes, such as exposure, brightness, and saturation, in the Project Browser. If you import an iMovie project that has these adjustments into Final Cut Pro, the adjustments are retained and appear in the Color area of the Video inspector as an iMovie item.
    Although you cannot modify the adjustments added in iMovie, you can choose whether they are applied to the clip or not.
    Note: Video adjustments you make to clips in the iMovie Event Browser are not retained and do not appear in Final Cut Pro.
    Turn a clipʼs iMovie adjustments on or off
    In the Timeline, select a clip with iMovie adjustments applied, and select or deselect the iMovie checkbox in the Color area of the Video inspector.
    Note: The iMovie adjustments appear only in the Timeline, not in the Event Browser.

  • How do I delete all empty graphics frames from a document?

    I have data merged a document and need to remove all the empty graphics frames as quick as possible.
    I have found solutions for deleting empty text frames but not graphics frames. Can somebody help with this as it will save soo much time and RSI!
    I found an applescript solution here:
    http://forums.adobe.com/thread/756281
    However, I am running Windows 7 and Id CC
    Cheers,
    Kris.

    Hi MToys
    I added a little to the script so that it will work on Ovals and Polygons also. [Not TextFrames]
    You just have to set the values for which of the frame types you want to delete.
    You can do this by setting the const values at the top of the script for DeleteRectangle, DeleteOvals, DeletePolygons
    There are a few uncertainties that I had:
    If an object is selected, should the script only delete that objects frame type.
    I.e., If you select an oval, should the script know to delete only ovals.
    At this point, I did not do that, rather it will just get the settings from the selected object, and delete all frame types with those settings
    I had to disable matching the transparency settings because they werent comparing correctly between different frame types
    Meaning, I made 3 frames, Oval, Rectangle and Polygon - no settings applied.
    I selected the oval and ran the script. It only deleted the oval even though set it to delete all.
    I found that the transparency settings werent matching... even though there werent any
    So, for now - its disabled.
    If someone can shed some light on this I would appreciate it.
    I tested the script on Mac Mountain Lion - ID CS6 and seems to work well
    Here is the script
    const Object_Style = false,
        Fill_Color = true,
        Fill_Tint = true,
        Fill_Transparency_Settings = true,
        Item_Layer = true,
        Stroke_Color = true,
        Stroke_Weight = true,
        Stroke_Type = true,
        Stroke_Transparency_Settings = true,
        Stroke_Tint = true,
        Stroke_Alignment = true;
    const DeleteRectangles = true,
        DeleteOvals = true,
        DeletePolygons = true;
    app.doScript(main, undefined , undefined, UndoModes.fastEntireScript, "INSERT_HERE_THE_SCRIPT_NAME")
    function main() {
        var myDoc = app.activeDocument;
        var mySel = app.selection;
        if (mySel.length > 0) {
            mySample = app.selection[0];
            if (mySample.constructor.name == "Rectangle" ||
                mySample.constructor.name == "Oval" ||
                mySample.constructor.name == "Polygon")
                var isSample = true;
                var objSty, fClr, fTint, fTrans, lay, sClr, sWeight, sType, sTrans, sTint, sAlign;
                GetProps(mySample);
        if (DeleteRectangles) {DeleteItems(myDoc.rectangles)}
        if (DeleteOvals) {DeleteItems(myDoc.ovals)}
        if (DeletePolygons) {DeleteItems(myDoc.polygons)}
        function DeleteItems(myGraphicFrames) {
            for (var i = myGraphicFrames.length-1; i >= 0; i--) {
                if (myGraphicFrames[i].graphics.length < 1) {
                    myGraphicFrames[i].select();
                    if (isSample) if (!checkProps(myGraphicFrames[i])) continue;
                    myGraphicFrames[i].remove();
        // ======================================
        function GetProps(mySample) {
            objSty = mySample.appliedObjectStyle;
            fClr = mySample.fillColor;
            fTint = mySample.fillTint;
            fTrans = mySample.fillTransparencySettings;
            lay = mySample.itemLayer.name;
            sClr = mySample.strokeColor;
            sWeight = mySample.strokeWeight;
            sType = mySample.strokeType;
            sTrans = mySample.strokeTransparencySettings;
            sTint = mySample.strokeTint;
            sAlign = mySample.strokeAlignment;   
        // ======================================
        function checkProps(myFrame) {
            var i=0;
            if (Object_Style) if (myFrame.appliedObjectStyle != objSty) return false;
            if (Fill_Color) if (myFrame.fillColor != fClr) return false;
            if (Fill_Tint) if (myFrame.fillTint != fTint) return false;
            if (Item_Layer) if (myFrame.itemLayer.name != lay) return false;
            if (Stroke_Color) if (myFrame.strokeColor != sClr) return false;
            if (Stroke_Weight) if (myFrame.strokeWeight != sWeight) return false;
            if (Stroke_Type) if (myFrame.strokeType != sType) return false;
            if (Stroke_Tint) if (myFrame.strokeTint != sTint) return false;
            if (Stroke_Alignment) if (myFrame.strokeAlignment != sAlign) return false;
            //if (Stroke_Transparency_Settings) if (myFrame.strokeTransparencySettings != sTrans) return false;
            //if (Fill_Transparency_Settings) if (myFrame.fillTransparencySettings != fTrans) return false;
            return true;

  • How to create a 'clone' linked text frame

    I have a large document, and the page numbering is not in a straight manner, as there are blank pages, which must be ignored for numbering. The blank pages are needed to make it easier for the printer, some pages need to be one-sided, others need to be two-sided.
    The numbering of the pages need to be done manually, or else I have to assign every page a section start, and for printing purposes this is kind of risky (page 1 is not really page 1 for instance...)
    OK, so far so good, I also need to create a table of contents, and check the document, and I was wondering if I could create a larger 'copy' of my manual page number, next to the page. At the moment I need to zoom in or select the frame and use apple-y to check the number.
    I create a slug area, I would like to put a larger textframe with the number in a larger corps in it, but it needs to 'link' to the original smaller text. Is this something that could be done by a utility or another way? It is not something I have to do every day, but I was just wondering if a kind of active 'clone' was possible. The 'copy' needs to be actively linked to the other textframe, every change must be implemented, but on a document page, not through a master page.
    Or else a page numbering scheme like 1,3,5,7 of 'ignore blank pages' would be appreciated

    That's a really bizarre way to number pages. Make sure you specify this to the printers, as a note to them. It's just not a normal way to number pages and printers would appreciate a heads up on it.
    There is no way to automate it as such. It would have to be manually updated when pages are added or moved around.
    You will still need two Master Pages
    Create an empty text frame on the Master Page on both spreads, make sure they are linked.
    Create a text file with sequential numbering from 1 - whatever the final page number is.  (excel can do this quite easily).
    Place the text file into the Main Pages at the starting page.
    You will then need to apply the Master Page without that text frame to every page that does not need a page number.
    You can do this easily by holding down Control (might be CMD on Mac) and then selecting the pages that don't require page numbers - then use the Apply Master Pages and select the master page to apply to those pages.

  • Unthread text frames indesign

    hi
    i develop an indesign extension with CS extension builder 2 and flashbuilder 4.6.
    how to unthread text frames ? i don't find any method or property in textframe class...
    thanks
    Simon

    hi
    thanks for your reply but it doesn't work because i want to keep the text in all textframe. I found a solution in 2 time duplic and remove :
    function unstory(qui:Document){
      for each(var stori in qui.stories){
       if(stori.textContainers.length>1){
      duplic(stori);
      remov(stori);
    function duplic(myStory){
                                  var myTextFrame;
                                  //Duplicate each text frame in the story.
                                  for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){
                                            myTextFrame = myStory.textContainers[myCounter];
                                            myTextFrame.duplicate();
    function remov(myStory){
                                  //Remove each text frame in the story. Iterate backwards to avoid invalid references.
                                  for(var myCounter = myStory.textContainers.length-1; myCounter >= 0; myCounter --){
                                            myStory.textContainers[myCounter].remove();

  • How does one completely empty a text frame of all text -- including overflow?

    Using something like myTexframe.contents = '' will only remove the visible text bounded by the frame and not any overflow. I need to empty the frame completely. Thanks.

    of course, what I just wrote will delete the entire story, i.e., the
    contents of any previous text frames as well. Is that what you want?

  • Selection text frame in linked text frame remove

    I chose in the text frame the linked text frames
    get out of text and I want to delete a text frame
    Is it possible that a command letter
    same thing selecting the external can

    Ok. Try now,
    var doc = app.activeDocument;  
    app.findGrepPreferences = app.changeGrepPreferences = null;  
    app.findGrepPreferences.findWhat = "~a";  
    var found = app.selection[0].findGrep();  
    for(var i =found.length-1;i>=0;i--)  
            var ip = found[i].insertionPoints[0];  
            if(found[i].allPageItems[0] instanceof TextFrame) 
                    var cont = found[i].allPageItems[0].texts[0].duplicate(LocationOptions.AFTER,ip);  
                    found[i].remove();  
    Regards,
    Chinna

  • Removing overset text in empty table rows (InDesign CS5.5)

    I have some overset text in a table that appears to be empty rows.  I've opened story editor so I can remove the text, but I can't select the area that's overset (the red lines).  How does one remove this overset stuff if you can't select it.

    Have you tried adjusting the height of the row to reveal the over set text?
    Or try placing your cursor in the cell in question and just hit the delete key...Sometimes invisible characters like column break can be accidently added.
    Or perhaps, highlighting the entire row and hit the backspace key.

  • Can an InCopy editor add, remove and edit a text frame placed inside the main story text frame?

    I think I already know the answer to this which is - no. I'll explain why I am asking the question in a second, but the reason I think the simple answer is no is because - text frames are controlled by a designer in the layout file, an editor using incopy can only edit the text and images placed inside text frames, and so cannot resize them, add or delete them.
    Ok, so the reason I have asked this.
    Is there a way around this so that editors in incopy can edit certain types of text frame that are contained within the main text frame? I'm using these text frames to contain specific paragraph styles, giving them a boxed look and also with an anchored icon in the top left of the text frame depending on the type of paragraph it is. See screenshot as an example of a green text frame that I am using to contain paragraphs of type "tip".
    If it is not possible for editors in incopy to add, edit or resize these text frames (green tip frame in the example above), then how else can I style these paragraphs to give the same visual appearance, but without the use of wrapping them in a text frame?
    One (not so good) way around this is for the designer to add the text frames in the layout file after he gets the content back from the editor, then moving the "tip" paragraphs into these newly created text frames. However when the editor updates the content in incopy and gets these new text frames in their copy, they can not then delete them if they wish to, or if they add or reduce content inside of these green text frames then the frames dont grow to fit their edited content. So I dont think its a solution for the designer to control the adding, removing and resizing of these frames.
    UPDATE: I have just discovered that once a text frame has been placed into the document by the designer and the editor updates their copy in incopy-  they can then use the "Position Tool" to select that text frame - allowing them to resize it, or delete it! Fantastic. But would the editor be able to add these frames in themselves to begin with? Maybe have a document containing all of the objects available to them, copy and paste one of them into the main document and edit its content? Does anyone have any advice on how to go about this? Essentially I would like the editor to control the insertion, editing and removal of these inline text frames.

    True. But when all I am trying to achieve is a border around a paragraph, use of a table seems overkill to me. But if thats the only solution I have so far then I will have to go down that route.
    It would be useful to have an object libraries panel in InCopy so that editors can drag across predefined text frames into their doc via InCopy, but I cant see that option in InCopy. is there one? I have also thought about exporting the frames as seperate InDesign Snippets and saving them to an objects folder, then when an editor needs to insert one into their doc they simply use File > Place > "Choose required text frame snippet". However I have found that InCopy can't place InDesign snippets so that theory was a failure. Is there another format I could use to save the objects and bring them into InCopy? List below shows my findings so far for trying to save/export a text frame from InDesign and then import into InCopy:
    InDesign Snippet (.idms) - can't import into InCopy
    InDesign Document (.indd) - imports content as an image - only editable in InDesign
    InDesign Template (.indt) - imports content as an image - only editable in InDesign
    InDesign Library (.indl) - can't import into InCopy - no panel available in InCopy for object libraries (that I can see...)
    InCopy Markup (.icml) - only imports the text, loses the text frame

  • How to remove  'Empty Demarcation'  in Text Elements.

    Dear All,
    To remove 'Empty demarcation' in the WAD output, I had modified the standard program - SAPLRSSV (for this i took  access key from SAP). 
    The text element : 301 was changed to blank  and it worked.
    Recently we had a support package upgrade to SAPKW70018. With this upgrade my previous change to the program got reverted back and so i need to do the change again.
    However,  I'm not able to retrieve the list of Text elements for this program (SAPLRSSV). I open the program and when i go to Text element,  following message is displayed :
    "Untranslated texts from master language DE will  also be displayed"
    But no list (no text elements) is displayed.
    My question : How do i retrieve this list  and can i use the same acess key again or do i need to take another one from SAP.
    Regards,
    Nagendra.

    Sorry, I was referring to the incorrect program SAPLRSSV instead of SAPLRRSV.  The problem has been resolved.
    Regards,
    Nagendra.

  • JS CS3 How can I find -and delete- anchored empty images frames

    I have a script that works fine with text,
    I need the same function, but find and remove anchored empty image frames
    thx
    var myDoc = app.activeDocument
    for(var myCounter = myDoc.textFrames.length-1; myCounter>=0; myCounter--)
    var myFrames = myDoc.textFrames[myCounter]
    if (myDoc.textFrames[myCounter].contents == ""){
    myDoc.textFrames[myCounter].remove()

    I'd do it this way:
    1. Grab the document's allPageItems.
    2. Iterate over it, ignoring text frames.
    3. Check to see: (a) if the parent is a character and (b) if the graphics collection of the page item is empty. If so, delete it.
    Dave

Maybe you are looking for

  • A photo has been found in the iPhoto Library that was not imported

    Every time I open iPhoto, I receive this error. I've already read through the posts on here that state to "simply go to the iPhoto library folder and delete.... " and so on an so forth.... My problem? I don't have an iPhoto Library folder in my Pictu

  • Need to split Quicktime movie files

    Hi Group! I have a bunch of movie files (MPEG4) that I need to split. I'm thinking a workflow like this: - open movie in qt pro - create out-point at the 65 minute mark - cut it - create new movie - paste it - rename it to oldname_"Part1" - save it -

  • ImageIcons loaded from database don't appear

    Hi, I create a JavaBean to show images from filesystem and database (oracle9i) in a JTable. The ImageIcons loaded from filesystem appears fine whith my defined DefaultTabelModel. The ImageIcons read from database (jdbc2) with the same DefaultTabelMod

  • Automatic tax code determination for service POs

    Hi Can anyone tell  about the possibilities of automatic tax code determination for the service purchase orders. Thanks in advance Durai

  • Question related to E-Business Suite (Business Group)

    Dear All, I just started my career as an oracle Functional Consultant (HRMS), I have questions related to Business Group - Why BG is a part of HRMS? Although we associates different profiles with it like, legal entity, which is used for financial pur