I am a beginner at writing scripts for InDesign (just started today!). I have somehow managed to write a script which auto-fills a text box with a list of the linked images within the document. However, when I group the text box with other objects or move it to another indesign doc, the script no longer works. I get an error that says "Object is invalid" with the source being "resFrame.contents = res.String;". Can someone please explain why this is happening and how it can be fixed?
Code below...
myDoc = app.activeDocument;
myPages = myDoc.pages.everyItem().getElements();
myDoc.viewPreferences.horizontalMeasurementUnits = myDoc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.INCHES;
for (var k = 0; k < myPages.length; k++) {
resString = myDoc.links.everyItem().name.join("\r");
resFrame = myFramelinks(myPages[k]);
resFrame.contents = resString;
}
function myFramelinks (page) {
var mFlinks = page.textFrames.item("linkslist");
return mFlinks;
}