Copy link to clipboard
Copied
I'm getting this error in a script, and can't figure out why. Earlier in the script, I open a dialog and then close it before I begin processing. The error occurs in processing when I try to set the CellStyle on some cells in a table.
I get the message in debug mode, so it could be complaining about the debug window. In non-debug mode, my script runs through but no styles are changed.
Anybody got any ideas?
Code except:
var currentLine = myFirst;
while (currentLine<myLast) {
var lineOffset = currentLine - myFirst;
with (myTable.rows.[currentLine]) {
if (myCellStyle != null && myCellStyle.text != '') {
cells.everyItem().appliedCellStyle = myCellStyle.text;
}
}
currentLine++;
}
Full script attached
Hi LeeShort,
The answer is in the question. A scriptUI modal dialog can't interact with UI DOM object until you close the dialog.
In your script, you call ProcessTable() from BtnOK.onClick event. When this event occurs, the dialog window is not yet closed.
In fact, you don't need the two lines:
win.GrpCancelOK.BtnOK.onClick = function () { this.parent.parent.close(1); ProcessTable();};
win.GrpCancelOK.BtnCancel.onClick = function () { this.parent.parent.close(1); };
because by default the window hid
...Copy link to clipboard
Copied
Hi LeeShort,
The answer is in the question. A scriptUI modal dialog can't interact with UI DOM object until you close the dialog.
In your script, you call ProcessTable() from BtnOK.onClick event. When this event occurs, the dialog window is not yet closed.
In fact, you don't need the two lines:
win.GrpCancelOK.BtnOK.onClick = function () { this.parent.parent.close(1); ProcessTable();};
win.GrpCancelOK.BtnCancel.onClick = function () { this.parent.parent.close(1); };
because by default the window hides itself on OK / Cancel.
So, use rather the value returned by the win.show() method (1 for OK, 2 for Cancel) and try something like this:
if (win.show() == 1) // OK
{
ProcessTable();
}
else
{ // Cancel
}
By the way, the body of ProcessTable() contains an undefined selection variable. Do you mean app.selection?
@+
Marc
Copy link to clipboard
Copied
Thanks for the thorough answer. That did the trick!
Copy link to clipboard
Copied
I know this is an old post but I'm hoping someone is still around to look at this. I have almost the same problem and I'm not sure how what you suggested fixed the problem. Here is my code for an onchange event on a pull down. Right now all I am trying to accomplish is placing an asset on the page when the pull down changes but I get the "Cannot handle the request because a modal dialog or alert is active" probably because the window that this pull down is still open even though I attempt to close it before interacting with the document. Any suggestions?
myEventPulldown.onChange = function ()
{
myDialog.close();
var myLibs = app.libraries;
var myLib = myLibs.item("testLibrary.indl");
var myAssets = myLib.assets;
var theAsset = myAssets[0];
try
{
theAsset.placeAsset(app.activeDocument);
}
catch(e)
{
alert(e);
}
}
Copy link to clipboard
Copied
You have to move your code out of the onChange function.
Set some variable that you read when the dialog is closed to know what to do...
Harbs
Copy link to clipboard
Copied
Wish I could give you some points for the correct answer! I hope a thank you will do.