• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Launch InCopy using VB script and AppleScript

Community Beginner ,
Jan 13, 2023 Jan 13, 2023

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)
}

 

TOPICS
InCopy workflow , Scripting

Views

279

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 13, 2023 Jan 13, 2023

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2023 Jan 13, 2023

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
}  

 

 

Screen Shot 37.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 13, 2023 Jan 13, 2023

Copy link to clipboard

Copied

It's a good one @rob day 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 15, 2023 Jan 15, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2023 Jan 15, 2023

Copy link to clipboard

Copied

LATEST

Yes 🙂 

 

▒► ID-Tasker / ID-Tasker Server - work smart not hard ◄▒

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines