11 Replies Latest reply on Dec 29, 2015 3:53 AM by pipiludaship6126065

    Relink does not seem to work

      I have the following line in my script:

      myDocument.Pages(x).AllGraphics(y).ItemLink.Relink "c:\...\myPicture.jpg"

      I intend to relink the picture to the graphic placeholder, but when I open the document after the script is executed, it still prompts with the window of "Fix Links Automatically". What did I do wrong? Thank you.
        • 1. Re: Relink does not seem to work
          Peter Kahrel Adobe Community Professional & MVP
          I wouldn't have thought that "c:\...\myPicture.jpg" is a legal path name on a PC. What do the three dots stand for?

          Peter
          • 2. Re: Relink does not seem to work
            Level 1
            After a relink you must always issue an update of the link.

            Dave
            • 3. Re: Relink does not seem to work
              Level 1
              To Peter,

              Thanks for your reply. "c:\...\myPicture.jpg" is just an example of a path. In the real script, it has the correct path of a jpg file.

              To Dave,

              Thank you for pointing it out. Yes, I added the update line:

              myDocument.Pages(x).AllGraphics(y).ItemLink.Relink "c:\...\myPicture.jpg"
              myDocument.Pages(x).AllGraphics(y).ItemLink.Update

              but, it does the same.

              When I open the Link window and examine the link, it is correct. Why, then, does that "Fix Links Automatically" window pop up?

              Thank you.
              • 4. Re: Relink does not seem to work
                Loic.Aigon Adobe Community Professional
                try update()
                what are these capitals all around ?
                myDocument.Pages(x).AllGraphics(y).ItemLink.Update
                you should have
                myDocument.pages(x).allGraphics(y).itemLink.update();
                • 5. Re: Relink does not seem to work
                  Peter Kahrel Adobe Community Professional & MVP
                  Loic,

                  >what are these capitals all around ?

                  Shoji uses VB.

                  Peter
                  • 6. Re: Relink does not seem to work
                    Loic.Aigon Adobe Community Professional
                    Very confused so and all apologizes to Shoji then.:-)
                    Loic
                    • 7. Re: Relink does not seem to work
                      Eric @ MCA Level 3
                      You can also try unlinking the graphic first. Then relink it and update. In CS2 I've had a few instances where files would show one graphic in the ID preview and print a different one. That was the only way to fix it.

                      The other option is that your document is corrupt. We've also seen rare cases where there would be a link listed that had no associated page number. The only way to get rid of those is to export the document to InDesign Interchange Format and then reimport them.
                      • 8. Re: Relink does not seem to work
                        Level 1
                        Hi Shoji,

                        I think that the most likely problem is that the reference to the graphic and (therefore) to the link are pointing to the wrong graphic/link. It looks like you're iterating through the graphics, given the use of variables in the Item--have you tried iterating in reverse order?

                        Thanks,

                        Ole
                        • 9. Re: Relink does not seem to work
                          Level 1
                          To loic,

                          We, Visual Basic programmers, are pretty sloppy about the cases. Sorry for the confusion.

                          To Eric and Ole,

                          I should have given a full explanation of what I am doing.

                          I created an InDesign document with some 50 images linked to it. All the images are jpg files stored in one folder. Then, I replaced all the image files with the blank image files of the same name. I am using this as a template. Furthermore, I deleted the folder of blank image files so that the links are no longer valid.

                          Now, I get a different set of the image files, all having the same name and size. However, most of these sets are not complete: there are many missing images. What I am trying by script as well as by VB is to check if each image file exists, and then to relink the image frames to the new image files if they exist and to delete the image frames (and pages) which do not have the corresponding image files.

                          All this works beautifully...almost. One problem is that after the script is executed, I open the document and encounter the "Fix Links Automatically" window. Yes, I choose this option and it does fix everything and I get the desired result. But I wonder why InDesign has to fix the links I thought I have established by script.

                          As Ole figured correctly, they have the old links. But doesn't Relink re-establish the link with the new image file?

                          I tried, as Eric suggested,

                          myDocument.Pages(x).AllGraphics(y).ItemLink.Unlink
                          myDocument.Pages(x).AllGraphics(y).ItemLink.Relink "c:\...\myPicture.jpg"
                          myDocument.Pages(x).AllGraphics(y).ItemLink.Update

                          without any success.

                          I am not sure of what effect it has, but I tried the iteration in reverse order as Ole suggested. It didn't help, either.

                          I would be grateful for any further comments. Thank you.
                          • 10. Re: Relink does not seem to work
                            AdobeScripts Level 3
                            I tried, as Eric suggested,

                            myDocument.Pages(x).AllGraphics(y).ItemLink.Unlink
                            myDocument.Pages(x).AllGraphics(y).ItemLink.Relink "c:\...\myPicture.jpg"
                            myDocument.Pages(x).AllGraphics(y).ItemLink.Update

                            without any success.

                             

                            because in CS4 you can't set new path as String - error in VB6 Object Browser function description - you need to use as argument File type - not String type:

                             

                            myLink = myDocument.Pages(x).AllGraphics(y).ItemLink 
                            strLink = "C:\1-Setup...." 'Path goes here 
                            Dim fso, fileLink
                            Set fso = CreateObject("Scripting.FileSystemObject")
                            Set fileLink = fso.GetFile(strLink) 'Path goes here
                            myLink.Relink(fileLink) 'fileLink is file, not string
                            myLink.Update()

                             

                            robin

                             

                            www.adobescripts.co.uk

                            • 11. Re: Relink does not seem to work
                              pipiludaship6126065

                              because in CS4 you can't set new path as String - error in VB6 Object Browser function description - you need to use as argument File type - not String type:


                              Yes , you are right

                              my code can work by modify it  as what you said