3 Replies Latest reply on Oct 20, 2009 7:47 AM by AdobeScripts

    Textframe problem

    Makkanj

      Hi

       

      I’m filling a document with textframes. Each textframe contains a text (article info) and a table with two cells (article number and price) below. When I have filled the first column of the page to the bottom of the page I want to start at the top of the next column. My program discovers that the textframe won’t fit in the column and it sets the new coordinates where I want to insert the textframe. But when the textframe is inserted the table is in the top of the textframe and the text is below instead of the opposite way as it should be.

       

       

       

      The looks something like this

       

       

      TextFrame = _MyPage.TextFrames.Add(myLayer)

       

      ' some code to calculate the position of the textframe

      TextFrame.GeometricBounds = myFramePos

       

      TextFrame.ParentStory.Texts.ItemByRange(TextFrame.ParentStory.Texts.Item(1).Characters.Ite m(1), TextFrame.ParentStory.Texts.Item(1).Characters.item(TextFrame.ParentStory.Texts.Item(1).C haracters.Count - 1)).Item(1).Contents = Text

       

      TextFrame.Tables.Add(InDesign2CS.idLocationOptions.idAtEnd, )

       

       

       

      Thanks

      Magnus

       

        • 1. Re: Textframe problem
          AdobeScripts Level 3

          hi Magnus,

           

          even if your new TextFrame is part(end) of your main story - you can(should) add new text as contents of last InsertionPoint - something like this:

           

          If TextFrame.InsertionPoints.Item(-1).Contents <> vbCR then

          TextFrame.InsertionPoints.Item(-1).Contents = vbCR

          ' just in case if your main text don't end with empty line

          ' you can also add FrameBreak, PageBreak, etc.

          End If

           

          TextFrame.InsertionPoints.Item(-1).AppliedCharacterStyle = myCharStyle

          or

          TextFrame.InsertionPoints.Item(-1).AppliedCharacterStyle = myCharStyle

          or any other pre-formatting code

           

          then

           

          TextFrame.ParentStory.InsertionPoints.Item(-1).Contents = Text

          Call TextFrame.ParentStory.InsertionPoints.Item(-1).Tables.Add

           

          thanks to this - you don't need to check/care if end of your Story is visible or overset

           

          of course, if your TextFrame is newly created and alone - not part of any Story - you can do:

           

          TextFrame.ParentStory.Contents = Text

          Call TextFrame.ParentStory.InsertionPoints.Item(-1).Tables.Add

           

          robin

           

          www.adobescripts.co.uk

          • 2. Re: Textframe problem
            Makkanj Level 1

            Hi

             

             


            Thanks, that solved my problem.

             

             


            But now I got another problem. I got these values in an array:

             

             


            Dim FramePos(3) As Object

             


            FramePos(0) = 21.0

            FramePos(1) = 84.75

            FramePos(2) = 22.0

            FramePos(3) = 28.25

             

             


            And then I want to set these values to TextFrame.GeometricBounds like this:

             

             


            TextFrame.GeometricBounds = FramePos

             

             


            But the values is TextFrame.GeometricBounds is

             

             


            (0) 21.0

            (1) 28.25

            (2) 22.0

            (3) 84.75

             

             


            Value 1 and 3 has switched position compared to what it looked like in FramePos.

             

             


            Anyone who got any idea what's wrong?

             

             


            /Magnus

            • 3. Re: Textframe problem
              AdobeScripts Level 3

              hi Magnus,

               

              GeometricBounds return/store values as (Y1,X1,Y2,X2), where:

               

              Y1,X1 - top-left corner

              Y2,X2 - bottom-right corner

               

              robin

               

              www.adobescripts.co.uk