6 Replies Latest reply on Nov 4, 2015 9:07 AM by Vamitul

    relink from different folders

    FlemmingP1234 Level 1

      Hi there

       

      Can't get the relink to work within vbscript. It should be simple, but it isn't (for me). Getting this error

      04-11-2015 11-10-55.png

       

      I have two scripts I use:

       

      One that saves information about my links in a text file. Doing this because I link to many different locations.

      One that needs to read this text file in order to relink to correct files again.

       

      First script:

      Rem To be used for Dumping all linked file information from InDesign

      Set objFSO = CreateObject("Scripting.FileSystemObject")

      Set myInDesign = CreateObject("InDesign.Application.CC.2015")

       

      'Get Indesign file name and use that to name txt file

      TextFileName = myInDesign.ActiveDocument.Name

      TextFileName = "C:\" + TextFileName + ".txt"

       

      Set ts = objFSO.CreateTextFile(TextFileName, True)

       

      If myInDesign.Documents.Count > 0 Then

       

      txt = "Saving all links from " & Chr(13) & Chr(10) & myInDesign.ActiveDocument.Name

       

      If MsgBox(txt, vbOKCancel) = vbOK Then

       

        For Each link in myInDesign.ActiveDocument.Links

             LinkPath = link.FilePath

             ts.WriteLine (LinkPath)

        Next

        ts.Close

        End If

      Else

        MsgBox "Hallo!?"

      End If

       

      Second script:

      Rem To be used for relinking files into InDesign

      Set objFSO = CreateObject("Scripting.FileSystemObject")

      Set myInDesign = CreateObject("InDesign.Application.CC.2015")

      TextFileName = myInDesign.ActiveDocument.Name

      TextFileName = "C:\" + TextFileName + ".txt"

      Set ts = objFSO.OpenTextFile(TextFileName)


      For Each link in myInDesign.ActiveDocument.Links

            WrongLinkPath = link.FilePath

             RightLinkPath = ts.ReadLine

             Relink(RightLinkPath)  <-------This won't work

      Next

      ts.Close