0 Replies Latest reply on Jun 2, 2014 4:04 AM by The Gothamite

    ClearTableStyleOverrides not working?

    The Gothamite

      Aloha everyone

       

      I have encoutnered something amazingly strange. Basically, I have a table style called codetable. In it Column #1 has all lines aligned to the right. Column #2 has all lines aligned to the left. It's something I have to apply manually to every Code Table I have in the document, because I need to apply line numbers that aren't alway 1 - n, but can be 22-24 and then 29-35.

       

      A typical line that I'd convert into the codetable would be

       

      01     function foo() {

       

      So I wanted to automate this. I have done this like so:

       

      1. Create Paragraph style called codetable that has a tab at 10mm. I do this so that the first column of the table is always 10mm wide.
      2. Apply said character style
      3. Convert Text to table, with table style codetable
      4. Clear overrides.
      5. Be happy.

       

      I thought I'd automate it and since I have an amazing script by Kai Rübsamen who helped me and my colleague out a few months ago.

       

      So, I think to myself, let's go grab that script, strip it of all unnecessary stuff and alter it. The result:

       

      var curSel = app.selection[0]; 
          app.findGrepPreferences.findWhat = "^\\d{2}\\t.+$"; //Find two digits, followed by tab, followed by something until the end of the line
      
          app.changeGrepPreferences.appliedParagraphStyle = "codetable"; //Apply Title Paragraph Style
          app.changeGrep() //do the Grep
          app.findGrepPreferences = null; //reset all the stuff.
      var curTable = curSel.convertToTable("\t"); //Convert to table, tab marks new cell.
          curTable.appliedTableStyle = "codetable"; //apply style 
          curTable.clearTableStyleOverrides( true ); //clear table style overrides.
          app.findGrepPreferences = null; //reset all the stuff.
      }
      

       

      This works like a charm, with one little problem. Line 09 doesn't work. At all. There's no error, there's no reaction in InDesign itself. No nothing. "No problem", I think to myself, "let's just override all cell styles". But that doesn't work either. I get an error going "curTable.clearCellOverrides( true) is not a function."

       

      Clearly I'm doing something wrong. I have no idea what it is or why it's wrong.

       

      Help, please?