Copy link to clipboard
Copied
My Indesign file has few hundred pages.
On the master page I have created one text frame and named it as "myframe"
A paragraph style of "apage_no" is applied to this text frame. Currently it does not have any content exept the style of "apage_no" is applied.
apage_no style description
--------------------------------
Font: Adobe Arabic
Size: 14pts
Bullets and Numbering : Numbers with ^#
Alignment : Centre
I have unlocked the textframe ("myframe") on document pages.
Now I am running this script to add a hair space to this particular text frame ("myframe") using the following script. Its not giving any error but its not working either.
=== Script ===
myDoc = app.documents[0];
var txtFrame = myDoc.textFrames.everyItem().getElements();
for(var i = 0 ; i < tf.length; i++)
{
if(txtFrame.name == "myframe")
{ txtFrame.insertionPoints[-1].contents = "hair space"; }
}
##i will use unicode of hairspace which I dont have handy
=== End ===
What am I missing ?
Thanks
Hi @Bedazzled532 , the first line of your for loop has the wrong variable name—tf isn’t defined. Try this
myDoc = app.documents[0];
var txtFrame = myDoc.textFrames.everyItem().getElements();
for(var i = 0 ; i < txtFrame.length; i++){
if(txtFrame[i].name == "myframe"){
txtFrame[i].insertionPoints[-1].contents = SpecialCharacters.HAIR_SPACE;
}
}
EDIT: You also need to include the i count variable, should be txtFrame[i] inside the loop.
Copy link to clipboard
Copied
Hi @Bedazzled532 , the first line of your for loop has the wrong variable name—tf isn’t defined. Try this
myDoc = app.documents[0];
var txtFrame = myDoc.textFrames.everyItem().getElements();
for(var i = 0 ; i < txtFrame.length; i++){
if(txtFrame[i].name == "myframe"){
txtFrame[i].insertionPoints[-1].contents = SpecialCharacters.HAIR_SPACE;
}
}
EDIT: You also need to include the i count variable, should be txtFrame[i] inside the loop.
Copy link to clipboard
Copied
@rob day Thank you so much. It worked.