Launch InCopy using VB script and AppleScript
Copy link to clipboard
Copied
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)
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
BTW, does your VB syntax works when you run it on Windows as a standalone command?
Copy link to clipboard
Copied
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
}
Copy link to clipboard
Copied
It's a good one @rob day
Copy link to clipboard
Copied
instead of myInCopy.Documents.Open
Shouldn't it be myInCopy.Open
Copy link to clipboard
Copied
Yes 🙂

