0 Replies Latest reply on May 28, 2013 10:59 AM by Beliakov

    How to write: use this script for all doc items? [CS6-jsx]

    Beliakov Level 1

      I have script for formatting one table. It gets table by selection under cursor (either insertionpoint.parent.parent or app.selection).

      So far i did this (in VBA of Word):

       

      mJvScr = D:\tab_format.jsx
      For Each myTable In myTexttostyle.Tables
      myInd.Select myTable
      myInd.DoScript mJvScr, idScriptLanguage.idJavascript
      Next ' myTable
      

       

      Then i desided to run this script for all my tables in document (and do it in hidden window of Indesign for additional speed up - but then method select() generate error).

      So i changed code to this:

       

      mJvScr = D:\tab_format_all.jsx
      'For Each myTable In myTexttostyle.Tables
      'myInd.Select myTable
      myInd.DoScript mJvScr, idScriptLanguage.idJavascript
      'Next ' myTable
      

      But script "tab_format_all.jsx" turned to be ingnored. Although, if i run it from Script panel, it does format all tables. I feel that script lose target doc, so produces no effect. Although in this script i have refer:

       

      myDocument = app.activeDocument;
      var myTables = myDocument.pages[0].textFrames[0].parentStory.tables;
      for (it=0; it<myTables.length; it++){ 
      ...
      }
      

      In one word: script does work as standalone staff, but doesn't if called from under VBA. And why?

      Thanks.