1 Reply Latest reply on Jun 11, 2009 8:15 AM by pasber

    Closing a new document with textvariable

    pasber

      1. In Indesign CS4 version 6.0.2 ,

      if I create a new document and insert a textvariable, I can save the document and I can close it.

       

      2. In scripting Indesign CS4 version 6.0.2 with VB.net (Visual Studio 2008 + Framework 3.5),

      if I open a document manually created under Indesign CS4 version 6.0.2 with a textvariable, I can save the document and I can close it.

       

       

      3. In scripting Indesign CS4 version 6.0.2 with VB.net (Visual Studio 2008 + Framework 3.5),

      if I create a new document and insert a textvariable, I can save the document, but I can't close it. Indesign give a win32 error.

       

      MyPub = myIndesign.Documents.Add(False)

      MySpread = MyPub.Spreads.Item(1)
      myTextFrames = MySpread.TextFrames
      MyInfos = myTextFrames.Add

      Dim FileNameVariable As InDesign.TextVariable = Nothing

      For Each Item As TextVariable In MyPub.TextVariables
            If Item.VariableType = idVariableTypes.idFileNameType Then
                     FileNameVariable = Item
                     Exit For
           End If
      Next
      Dim FileNameVariableInstance As InDesign.TextVariableInstance = Nothing
      FileNameVariableInstance = MyInfos.TextVariableInstances.Add(idLocationOptions.idAtBeginning)
      FileNameVariableInstance.AssociatedTextVariable = FileNameVariable

       

      MyPub.Save(FullPath)   'OK

      MyPub.close               'Error Win32 in Indesign.exe

       

      I try to save the document before creating the FileNameVariableInstance but it's the same result.

       

      Do you know a way to do it ?

       

      Regards

        • 1. Re: Closing a new document with textvariable
          pasber Level 1

          After searching a lot I have finally found the solution :

           

          MyPub = myIndesign.Documents.Add(False)

          MySpread = MyPub.Spreads.Item(1)
          myTextFrames = MySpread.TextFrames
          MyInfos = myTextFrames.Add

           

          Dim MyVars as Indesign.TextVariables = MyPub.TextVariables


          Dim FileNameVariableInstance As InDesign.TextVariableInstance = Nothing
          FileNameVariableInstance = MyInfos.TextVariableInstances.Add(idLocationOptions.idAtBeginning)
          FileNameVariableInstance.AssociatedTextVariable = MyVars.item(8) ''index of the textvariable equals to idFileNameType

           

          MyPub.Save(FullPath)   'OK

          MyPub.close               'OK