2 Replies Latest reply on Jul 11, 2013 2:38 AM by panky245

    remove specific text variables (IDCS6)


      Hello everybody,


      Is it true we cannot delete text variables in InDesign? I am trying something below:


      #target "InDesign"

      if(app.documents.length > 0){

        var myDoc = app.activeDocument;

        var myVariables = myDoc.textVariables;



      for(var i = 0; i < myVariables.length; i++){

      if(myVariables[i].variableType == VariableTypes.CUSTOM_TEXT_TYPE){

          var MyTextVarName=myVariables[i].name;


          MyTextVarName.remove();//getting error here. Though when I refer to InDesign CS6 Object Reference (thanks to Jongware), function seems to be available.  Any clues






      I have got work around with but I still need to delete specific text variables.


      1. app.activeDocument.textVariables.item ('TXT').variableOptions.contents = "";




        • 1. Re: remove specific text variables (IDCS6)
          -hans- Level 4



          MyTextVarName is a string, not a reference.


          Also your approach is to complicated so as you already know the name of the variable you want to remove and there's not need for looping so.


          var myCustomTextVariableName = 'sampleTV'


          var tV =  app.activeDocument.textVariables.itemByName(myCustomTextVariableName);




                  alert('Textvariable ' + myCustomTextVariableName + ' is not valid in active Document')


          • 2. Re: remove specific text variables (IDCS6)
            panky245 Level 1

            Thanks -hans-. Ican see the error pointed by you.


            Little bit of modification and things works as required.


            Much appreciated.