Skip to main content
Participant
January 13, 2023
Question

Launch InCopy using VB script and AppleScript

  • January 13, 2023
  • 4 replies
  • 588 views

Hi,

I am using following script for opening a doc in InCopy, but these steps are not working. (In Windows, only InCopy is getting launched but document is not opening)

Please check if I am missing something.

 

function inCopyWordWin(filePath) {
try {
var myVBScript = 'Set myInCopy = CreateObject("InCopy.Application")\r'
+ 'myInCopy.Visible = True\r' + 'myInCopy.Documents.Open "'
+ filePath + '"\r';
app.doScript(myVBScript, ScriptLanguage.VISUAL_BASIC)
}
catch (e) {
alert(e.message);
}
}

 

function inCopyWordMac(filePath) {
var myAppleScript = 'tell application "Adobe InCopy"\r'
+ 'open file "Macintosh HD:' + filePath + '"\r'
+ 'end tell';
app.doScript(myAppleScript, ScriptLanguage.APPLESCRIPT_LANGUAGE)
}

 

This topic has been closed for replies.

4 replies

Inspiring
January 15, 2023

instead of myInCopy.Documents.Open
Shouldn't it be myInCopy.Open

Robert at ID-Tasker
Legend
January 15, 2023

Yes 🙂 

 

rob day
Community Expert
Community Expert
January 13, 2023

Hi @devs27984525 , You also might look at the Bridgetalk object, which would let you open inCopy via JS. Here’s a sample:

 

var bt = new BridgeTalk();  
bt.target = "incopy";  
bt.body = "var mynum = 50; \r" + incopyScript.toString() + "\rincopyScript();";
//the inCopy JS function
$.writeln(bt.body)


bt.onResult = function(resObj) { 
    //get a string sent back from inCopy
    alert("InCopy sent this message back to InDesign. " + resObj.body);
}  

bt.onError = function( inBT ) { alert(inBT.body); };  
bt.send();  
      

/**
* An InCopy function 
* @ return string 
*/
function incopyScript() {  
    //InCopy is running
    alert ("From Incopy: Opening a Document" );
    
    //open a file named Test.icml on the desktop
    var f = Folder.desktop + "/Test.icml"
    var doc = app.open(new File(f))

    //a string returned back to InDesign
    var s = " Your document has been opened. Its name is " +doc.name + ". The sent variable mynum = " + mynum;
    return s
}  

 

 

Loic.Aigon
Legend
January 13, 2023

It's a good one @rob day 

Loic.Aigon
Legend
January 13, 2023

BTW, does your VB syntax works when you run it on Windows as a standalone command?

Loic.Aigon
Legend
January 13, 2023

Not familiar with VB but wouldn't the Open method expect parenthesis?

var myVBScript = 'Set myInCopy = CreateObject("InCopy.Application")\r'
+ 'myInCopy.Visible = True\r' + 'myInCopy.Documents.Open( "'
+ filePath + ' )"\r';

 

FWIW

Loic