change text frame options based on content paragraph style
Hi Experts,
I write a script to change the text frame options when that frame contains particular style(s), but I am getting error as object is invalid when I pass the 12th line. Can some one please help me to find out the error?
And can some on please teach me where should I exactly find what error it is on ESTK?
var mystyle=["caption"];
for(k=0;k<mystyle.length;k++)
{
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
app.findGrepPreferences.appliedParagraphStyle = mystyle
; var fnd = app.findGrep();
for (a=0; a<fnd.length; a++)
{
var myTextFrame = app.selection[0].textFrames[0];
alert (myTextFrame);
myTextFrame.textFramePreferences.firstBaselineOffset=FirstBaseline.ASCENT_OFFSET;
myTextFrame.textFramePreferences.minimumFirstBaselineOffset=6;
myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);
}
app.findGrepPreferences = null;
app.changeGrepPreferences = null;
}
