Copy link to clipboard
Copied
I have my VBS code which detects if Illustrator is running and launches it if not. The problem is, it doesn't really stop and wait with the rest of the code while Illustrator is launching, and appears to be running code too soon and causing errors.
I found this thread on our forum, but it looks like it's dealing with a document being loaded in the app?
Copy link to clipboard
Copied
can you do something like a while loop that executes until the file is completely loaded? For instance whatever document properties are missing when the rest of your script starts executing.. perhaps each of the properties causing your errors.
idk VBS but in JS:
In this example we want to verify that there is an active document, that we can access the layers in the document and that we can access the swatches. if any of those fail, then the loop continues.
function test()
{
var docReady = false;
var MAX_TRIES = 1000;
var curTries = 0;
while(!docReady && curTries < MAX_TRIES)
{
try
{
curTries++;
$.writeln("trying number " + curTries);
var docRef = app.activeDocument;
var layers = docRef.layers;
var swatches = docRef.swatches;
docReady = true;
}
catch(e)
{
$.writeln("doc not ready");
}
}
$.writeln("finished.");
}
test();
just a thought. i don't know whether AI will continue to open the file during the while loop execution or if the loop will pause illustrator until it's done.
Copy link to clipboard
Copied
Good idea, I can try to make a VB try-catch approximation which repeats in a loop until one of the code lines which depends on the Illustrative being loaded and running, does not error. I'll try this and say what I find.
Copy link to clipboard
Copied
Any chance you have this one figured out? I am recently running into the same problem in VB.
Copy link to clipboard
Copied
I will try to find what this was and see if I actually did it ![]()
Copy link to clipboard
Copied
Thanks, Silly-V. I am very new with VB and been racking my brain all last night.
Copy link to clipboard
Copied
Found out VBS isn't compatible with try/catch or wait. This may be a hack but seems to do the job for now.
Do While num < 1000
Set appRef = CreateObject("Illustrator.Application.CS5")
num = num + 1
Loop
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more