Update, after playing with this for a few hours, I've managed to get around the error messages, but the problem now is that when the list pops up, some of the documents are listed as many as 3 times. I'm having some success in getting the active document to be the highlighted document by default, but it's still a little erratic. I'm pulling my hair out over this one. Can someone spot the error - it's almost there
var aDoc = app.activeDocument; var AllDocs = app.documents; var actLay = aDoc.activeLayer; var IndexCurrent = app.index if (AllDocs.length > 1) { var itemDoc = null; var win = new Window("dialog","Switch Documents"); this.windowRef = win; win.Txt1 = win.add ("statictext", undefined, "Switch to which document?"); win.NewList=win.add ("dropdownlist", undefined) for (var m = 0; m < AllDocs.length; m++) { win.NewList.add("item", AllDocs[m].name) win.NewList.add("item", aDoc.name) if (AllDocs[m] == app.activeDocument) {win.NewList.selection = m}; } itemDoc = win.NewList.selection.index; win.cancelBtn = win.add("button", undefined, "Switch"); win.cancelElement = win.cancelBtn; win.NewList.onChange= function () { itemDoc = win.NewList.selection.index; return itemDoc; } win.show(); app.activeDocument = app.documents[itemDoc]; app.refresh(); }