1 Reply Latest reply on Jul 11, 2008 3:00 AM by sstanleyau

    [AS] text box mystery??

    Kevin Parrott Level 2
      Hi

      I am experiencing a strange issue with a text box, with text in it, was hoping that some one may have some idea's as to why?

      I create a new document that has a rectangle in it, I save the doc, then I add
      a text field and text via script , in this text field is the dimensions of the rectangle, the date and the file name, the script then saves the doc and closes it, this all works perfectly.
      If I need to edit the file I need to update the text fields information to comply with, date etc, so I have the script if exists already a text field delete it and then replace it with
      a new text field with new information in it, this works, but the dimensions of the rectangle come back incorrect, (rectangle not touched at all by me).
      If I manualy delete the text field then run the script to add another text field the dimensions of the rectangle come back as correct.

      Snippet of code (it's not pretty) that revolves around my issue, ant ideas any one?

      tell every page of myDocument
      set my_Document to get name of myDocument as text
      tell application "Adobe InDesign CS3"
      tell document 1
      if exists text frame 1 of myDocument then
      delete text frame 1
      tell application "Adobe InDesign CS3"
      if modified of active document is true then
      tell active document to save
      end if
      end tell
      set title_Rect to make new text frame at page 1 of myDocument with properties {stroke color:swatch "None" of myDocument, geometric bounds:mySlugTitleBounds, fill color:swatch "None" of myDocument}
      set text of title_Rect to (my_Document & " - " & _Date & " - " & _PageHeight_Width & return & return & " " & _Window)
      move title_Rect to {(myPageWidth - myPageWidth + 1), (myPageHeight + 12)}
      repeat with myCharacterCounter from 1 to (count characters of parent story of title_Rect)
      set properties of character myCharacterCounter of parent story of title_Rect to ¬
      {applied font:"Arial", font style:"Regular", point size:"7.5", underline:false, fill color:"Keyline"}
      end repeat
      else
      tell application "Adobe InDesign CS3"
      set titleRect to make new text frame at page 1 of myDocument with properties {stroke color:swatch "None" of myDocument, geometric bounds:mySlugTitleBounds, fill color:swatch "None" of myDocument}
      set text of titleRect to (my_Document & " - " & _Date & " - " & _PageHeight_Width & return & return & " " & _Window)
      move titleRect to {(myPageWidth - myPageWidth + 1), (myPageHeight + 12)}
      end tell
      ------- set font size and point size -------
      repeat with myCharacterCounter from 1 to (count characters of parent story of titleRect)
      set properties of character myCharacterCounter of parent story of titleRect to ¬
      {applied font:"Arial", font style:"Regular", point size:"7.5", underline:false, fill color:"Keyline"}
      end repeat
      end if
      end tell

      Cheers
      Kev
        • 1. Re: [AS] text box mystery??
          sstanleyau Level 4
          I'm not sure what you're getting at, but this sort of thing struck me:<br /><br />> repeat with myCharacterCounter from 1 to (count characters of parent story of<br />> titleRect) <br />> set properties of character myCharacterCounter of parent story of titleRect to<br />> ¬ <br />> {applied font:"Arial", font style:"Regular", point size:"7.5",<br />> underline:false, fill color:"Keyline"}<br /><br />Why are you doing it a character at a time? Better to  just:<br /><br />set properties of parent story of titleRect to ¬<br />{applied font:"Arial", font style:"Regular", point size:"7.5",<br />underline:false, fill color:"Keyline"}<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au>