0

How do I quit InDesign and open Illustrator using InDesign scripting? This is my code:

// closing the InDesign document here
myDocument.close(SaveOptions.NO);

// change the script's target to Illustrator
#target illustrator

app.documents.add(DocumentColorSpace.CMYK, width = 1024, height = 768); 

But here the script is not quitting InDesign, and only opening Illustrator. How can I resolve this?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Padmashree
  • 7
  • 1
  • 4

4 Answers4

0

@Padmashree --

Hmm, maybe it is possible that InDesign is interrupting your statement  myDocument.close ( SaveOptions.NO );  in some way?

Try this and see if it works:

 // the original interaction and warning settings of the application
var oldInteractionPrefs = app.scriptPreferences.userInteractionLevel;

// prevent interaction and warnings from interrupting script
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

// close the active document without saving
app.activeDocument.close(SaveOptions.no);

// reset interactions to original settings
app.scriptPreferences.userInteractionLevel = oldInteractionPrefs;

This is changing the "user interaction level" of the application to "NEVER_INTERACT" to ignore all modal dialog windows (error messages, other application alerts).

I found this solution here at:


But of course,  myDocument.close ( SaveOptions.NO );  itself only closes an InDesign document, and not the program.

app.quit(SaveOptions.NO)  apparently closes InDesign (not tested, found at: http://jongware.mit.edu/idcs5js/pc_Application.html).

Community
  • 1
  • 1
Ian Campbell
  • 2,678
  • 10
  • 56
  • 104
  • I got the script from below link and it works fine for me... http://forums.adobe.com/message/4603168#4603168 Thank you for reply :) Have a nice day :) – Padmashree Aug 09 '12 at 03:57
  • @Padmashree -- Ah, `BridgeTalk`, I see. Also look at http://kasyan.ho.com.ua/convert_cmyk-rgb_images_to_grayscale.html for a good reference (this is for InDesign communicating with Photoshop, though). – Ian Campbell Aug 09 '12 at 04:38
0

If you are using Win7 try next

var mySelect = app.selection[0].graphics[0].itemLink
var myFilePath = mySelect.filePath;
var myProg = "Illustrator";
var myFile = myFilePath; 
var myScript = "";
myScript += "Dim WshShell\r";
myScript += "Set WshShell = CreateObject(\"WScript.Shell\")\r";
myScript += "ReturnCode = WshShell.Run (\"\"\""+myProg+".exe\"\"\"\""+myFile+"\"\"\",1)\r";
app.doScript(myScript, ScriptLanguage.VISUAL_BASIC);
Anatoly
  • 36
  • 3
0

I came across this thread just barely and was actually looking for a way to close Photoshop via extendscript. If that is what you were looking for use this:

    var idquit = charIDToTypeID( "quit" );

executeAction( idquit, undefined, DialogModes.ALL );
0

If you are using Mac OS try next

1.open script editor

2.write blow applescript code

tell application "Adobe Indesign CC 2019" to quit (break line) tell application "Adobe Illustrator CC 2019" to activate

Xiaoqin
  • 1
  • 2