Copy link to clipboard
Copied
Hi,
I can check the below code whether a textframe contains text variable or not.
I need to get the extra contents of that textframe which contains text variable. How can i check this?
Code to find Text Variable:
var paraTxtVarBool = findSpecialCharacters(txtFram, "~Y");
function findSpecialCharacters(sel, findGrp)
{
var found = 0;
try{
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findChangeGrepOptions.includeMasterPages = true;
app.findGrepPreferences.findWhat = findGrp
res = sel.findGrep();
if(res.length > 0)
{
found = 1;
}
app.findGrepPreferences = app.changeGrepPreferences = null;
}catch(e){return found}
return found;
}
Copy link to clipboard
Copied
Hi Sudha,
look at parentTextFrames[0].texts[0] of the first or last insertion point of the found text.
From there you could extract the value of contents .
Regards,
Uwe
Copy link to clipboard
Copied
Hi,
thank you.. I will check and get back...
Copy link to clipboard
Copied
Hi,
The above code returns the contents of the text frame of text variable found. But how can i check whether that a text frame contains extra contents or not when it contains text variable?? Also the text frame may contains more than one text variable. In that case how to check??
We can see visually but how to confirm that in scripting?
Copy link to clipboard
Copied
Hi Sudha,
look for textVariableInstances in a text frame or a story.
You could read out the associatedTextVariable from that and even the resultText.
storyOffset will give you the first insertion point in the story.
storyOffset.index the position of the insertion point relative to its parent, a story or a cell ( if found in a table ).
What do you mean with extra contents?
For all text formatted you could inspect textStyleRanges or even single characters with texts[0] of a story or a text frame and inspect the contents.
textFrame.texts[0].textVariableInstances.everyItem().getElements();
textFrame.texts[0].textStyleRanges.everyItem().getElements();
textFrame.texts[0].characters.everyItem().getElements();
Maybe some screenshots would help to illustrate your problem?
Regards,
Uwe
Copy link to clipboard
Copied
Hi,
Thank you for the replay...
Refer the screenshot for text with text variable. Others text except text variable.
I have followed the below steps.
1. Get the count of paragraph style text variable.
2. Get the count of character style text variable.
3. Get the count of contents length.
4. If i get difference in count of both para and char text variable count and contents length, considering that textframe contents extra contents.