I have a script below that opens an Indesign page and places several graphics files in rectangles. I need to modify the script to apply an already created object style to the rectangles based on their script labels.

Thanks'

Script below.



#targetengine "session"
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

var month, date, year, week, myDocument;
var curDate = new Date();
//"Macintosh HD:users:marshall:documents:comix:GGDailyBlank.indd"
var myTemplatePath = "/c/Comic/GG-Sun-Blank.indd";
//app.open(myTemplate);


var win = showDialog();


function showDialog() {
var win = new Window('palette');
with(win){
win.Pnl = add('panel', undefined, ' Date / Month / Year / week');
win.Pnl.orientation = 'row';
with(win.Pnl) {
win.Pnl.day = add('edittext');
win.Pnl.day.text = curDate.getDate();
win.Pnl.day.text = (win.Pnl.day.text < 10) ? '0' + win.Pnl.day.text : win.Pnl.day.text
win.Pnl.day.preferredSize = [35,20];

win.Pnl.month = add('edittext');
win.Pnl.month.text = curDate.getMonth() + 1;
win.Pnl.month.text = (win.Pnl.month.text < 10) ? '0' + win.Pnl.month.text : win.Pnl.month.text
win.Pnl.month.preferredSize = [35,20];

win.Pnl.year = add('edittext');
win.Pnl.year.text = curDate.getFullYear();
win.Pnl.year.preferredSize = [50,20];

win.Pnl.week = add('edittext');
//win.Pnl.year.week = week();
win.Pnl.week.preferredSize = [50,20];

}
win.btnOk = add('button', undefined, 'Import Comic');
win.btnOk.onClick = setDate;
};
win.center();
win.show();
return win;
}
function setDate() {
month = win.Pnl.month.text;
date = win.Pnl.day.text;
year = win.Pnl.year.text;
week = win.Pnl.week.text;
// OK we close the window and do the import
//win.close();
importComics();
}




function importComics() {
try {
myDocument = app.open(new File(myTemplatePath));
} catch (e) {
alert(e);
}
try {
//set comic1 to "macintosh Hd:users:marshall:documents:comics:" & DYear & Dmonth & Dday & "pzjud-a.pdf"
var comics = new Array();
// REPLACE with own filepaths, could be
//comics.push(new File("/c/comics/" + year + month + date + "pzjud-a.tif"));
comics.push(new File("/c/Comic/Comics/pe09"+ month + date + "cmy_hs.tif"));
comics.push(new File("/c/Comic/Comics/pe09"+ month + date + "k_hs.tif"));
comics.push(new File("/c/Comic/Comics/gar" + week+ "qsc.tif"));
comics.push(new File("/c/Comic/Comics/gar" + week + "qsl.tif"));
comics.push(new File("/c/Comic/Comics/dt09"+ month + date + "cmy_ht.tif"));
comics.push(new File("/c/Comic/Comics/dt09"+ month + date + "k_ht.tif"));
// comics.push(new File("/c/Comic/Comics/comic4-" + year + "-" + month + "-" + date + ".jpg"));
// comics.push(new File("/c/Comic/Comics/comic5-" + year + "-" + month + "-" + date + ".jpg"));
} catch (e) {
alert("Error assigning images for import\n" + e);
}

for (i = 1; i <= comics.length; i++) {
// Script label of the rectangles/pageitems to place the graphics into
try {
var myRect = myDocument.pageItems.item("comic" + i);
myRect.label;
} catch (e) {
alert("Could not locate the frame with scriptlabel comic" + i + ", exiting");
exit();
}

try {
myRect.place(comics[i-1]);
} catch (e) {
alert(e);
}
//myRect.fit(FitOptions.CONTENT_TO_FRAME);
}
}