before run input your variable name (displayed in Text:Text Variables menu)
var myDoc = app.activeDocument; var myCap = myDoc.textVariables.item("yourVarName"); // <== edit here var l = myCap.associatedInstances.length; while (l--) myCap.associatedInstances.convertToText();
However much easier is to mouse-klick in UI:
select anyone of your caption instances ==>
go to Text:Text Variables:Define window ==>
choose your variable ==>
klick "convert to text" button.
Did you mean the 0 in the last line to actually be an l? As in, it should be:
Sorry, I misunderstood what the code was doing and thought that was a typo.