7 Replies Latest reply on Dec 29, 2015 3:57 AM by pipiludaship6126065

    [VBA] Runtime Error 35869 when trying to relink image

    Cookie4ddict

      Hi Folks!

       

      I'm opening an indesign document and searching for an existing image. I know the link of the image is index number 9. After finding the image I try to relink it. Every time I tried I got the same Runtime error which tells me, the ressource can't be created with the given URI.

       

      Here you can see my testing code:

       

      Option Explicit

       

      Dim myIndesign As InDesign.Application
      Dim myDocument As InDesign.Document


      ''
      '
      ' Starts InDesign and opens document
      '
      ''

      Function IndesignStartup()
          Set myIndesign = CreateObject("InDesign.Application")
          Set myDocument = myIndesign.Open(ActiveWorkbook.Path + "/20102127_8439_Risiko_analyseXL.indd")
          ChangeMasterSpreads
      End Function

       

      ''
      '
      ' Changes adress on master spread
      ' and image on next master spread
      '
      ''
      Function ChangeMasterSpreads()
          Dim myMasterPage As InDesign.MasterSpread
          Dim textFrames As InDesign.textFrames
          Dim textFrame As InDesign.textFrame
         
          Dim imageMasterPage As InDesign.MasterSpread
          Dim imageLink As Link
             
          Set myMasterPage = myDocument.MasterSpreads.FirstItem
          Set textFrames = myMasterPage.textFrames
          Set textFrame = textFrames.Item("adress")
          textFrame.contents = "Test for replacing adress"
         
          Set imageLink = myDocument.Links.Item(9)

          MsgBox (ActiveWorkbook.Path + "\lauterbach.jpg")
           imageLink.Relink (ActiveWorkbook.Path + "\lauterbach.jpg")

          imageLink.Update
      End Function

       

      Thanks for trying to help me!

       

      With kind regards,

       

      Steffi