4 Replies Latest reply on Oct 18, 2009 8:39 AM by AdobeScripts

    Change itemLink

    NgoiSang88888

      I want to change the itemLink paramtere of a Story but this is a read-only property, how can I do this? Or more generally: how can I link a file to a story in
      InDesign with Indesign Script.

       

      PS I'm using JavaScript

        • 1. Re: Change itemLink
          [Jongware] Most Valuable Participant

          You cannot change the link from one file to another. If you could, you could create a file out of nothing (by setting the link to a non-existing file).

           

          The other way around you can use document.place (filename) -- be sure the TextPreference linkTextFilesWhenImporting is set to true to get a link.

           

          What are you trying to achieve?

          • 2. Re: Change itemLink
            NgoiSang88888 Level 1

            I have a masterpage with our textframes in one Story. I want to add new pages to the document with this master applied. Cosecutively I want to link a file to this story (a docx-file). There is not already a file linked to the Story.

            • 3. Re: Change itemLink
              NgoiSang88888 Level 1

              I see I can place it with document.place, but then I have to assign it to a Story manually and that is not what I want...

               

              Somebody?

              • 4. Re: Change itemLink
                AdobeScripts Level 3

                I see I can place it with document.place, but then I have to assign it to a Story manually and that is not what I want...

                when you place file - you get reference to it

                or you can first create "container" and place your file into it

                 

                so in your case - you can (VB example):

                 

                1) create new TextFrame

                Set myTF = myDoc.Pages.Item(1).TextFrames.Add

                 

                2) place your text file to .ParentStory.Texts.Item(1) of this new TextFrame

                call myTF.ParentStory.Texts.Item(1).Place("c:\qqq.txt")

                 

                3) connect your destination story's LastTextFrame with this new TextFrame

                (for ID CSx < 3)

                myMainStory.TextFrames.Item(-1).NextTextFrame = myTF

                 

                or

                (for ID CSx > 2)

                myMainStory.TextContainers.Item(-1).NextTextFrame = myTF

                 

                4) delete myTF and reflow your myMainStory

                 

                robin

                 

                www.adobescripts.co.uk