2 Replies Latest reply on Apr 2, 2008 7:28 AM by (Olav_Kvern)

    CS3, VBS, Selecting multiple text frames in a region is very slow

      Hello,

      I'm writing a script that selects a large crossword grid (19cm x 19cm), and changes the font and alignment before exporting out as an eps.
      When I run the code below, it starts off selecting the frames quickly and then gradually slows to a crawl, before being painfully slow at the end. It takes 35mins to run it on the clues grid and then the solution grid.

      Can anyone think of a way to rewrite the code so it's quicker? Or are there some settings that could be changed so it handles better? I've changed the Display Performance settings to the bare minimum, but it only has a little effect.

      Thanks for any help ... Nigel

      rem Selects grid and fixes text
      Set mySolPage = myDocumentA.Pages.Item(2)
      For myCounter = 1 to mySolPage.TextFrames.Count
      Set myTextFrame = mySolPage.TextFrames(myCounter)
      myBounds = myTextFrame.GeometricBounds
      If myBounds(0) > 35 and myBounds(1) > 5 and myBounds(2) < 240 and myBounds(3) < 210 Then
      myTextFrame.select(idSelectionOptions.idaddTo)
      myTextFrame.Texts.Item(1).AppliedFont = "Tahoma"
      myTextFrame.Texts.Item(1).fontstyle = "Bold"
      myTextFrame.Texts.Item(1).baselineShift = 0
      myTextFrame.textFramePreferences.VerticalJustification = idVerticalJustification.idCenterAlign
      myTextFrame.textFramePreferences.ignoreWrap = 1
      myTextFrame.textFramePreferences.firstBaselineOffset = idFirstBaseline.idAscentOffset
      else
      myTextFrame.select(idSelectionOptions.idremoveFrom)
      End If
      Next
        • 1. Re: CS3, VBS, Selecting multiple text frames in a region is very slow
          Level 1
          hi Nigel,

          1) move your TextFrames to separate layer - then you don't need to check Bounds
          2) turn OFF redrawing:

          Property EnableRedraw As Boolean
          Member of InDesign.ScriptPreference
          If true, enables redraw during script execution.

          3) create and use Para or Char Style - then you don't need to apply many times same params

          myTextFrame.ParentStory.Texts.Item(1).AppliedParagraphStyle = myParaStyle
          or
          call myTextFrame.ParentStory.Texts.Item(1).ApplyParagraphStyle(myParaStyle,True)

          and why you have:

          [...]
          else
          myTextFrame.select(idSelectionOptions.idremoveFrom)
          [...]

          there is no Select command ...

          but if you have Select command somewhere before - you can iterate .Selection collection - so you don't need to check bounds

          robin

          --
          www.adobescripts.com
          • 2. Re: CS3, VBS, Selecting multiple text frames in a region is very slow
            Level 1
            Hi Nigel,

            It would be much faster to use find/change to do the text formatting, or just apply a style to the crossword text and then edit the style as needed. There shouldn't be any need to select the text or text frames in this script.

            Thanks,

            Ole