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

launch InDesign CC2015 using VBscript

Participant ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Hi All,

We using this vb code to launch InDesign CC2015 in widows7.

Set myInDesign = CreateObject("InDesign.Application.CC2015")

Msgbox("This message from Vbscript")

myJavaScript = "D:\Program Files (x86)\Adobe\Adobe InDesign CC 2015\Scripts\Scripts Panel\Test.jsx"

Msgbox("This message from Vbscript-Script")

myInDesign.DoScript myJavaScript, 1246973031

But we are getting the below error message while run the Vbscript.

error.png

Help me to suggest better way..

Thanks in Advance,

Mahesh

TOPICS
Scripting

Views

3.3K

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 ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

I can't say that's the issue but backslashes can be escaping characters so once interpreted it can be read as

"D:*rogram Files (x86)*dobeAdobe InDesign CC 2015*cripts*cripts PanelTest.jsx"

* means any interpretation of escape the following character.

Use this instead:

D:\\Program Files (x86)\\Adobe\\Adobe InDesign CC 2015\\Scripts\\Scripts Panel\\Test.jsx"

In clear english, escape the escaping character…

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
Guru ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Hi Loic,

The escaping here is not the issue, (The codes in VB and not js) \ doesn't need escaping in the visual basic family.

In fact escaping it would cause problems.

Regarding the Op's problem see

Re: InDesign CS6 scripts don't work on CC anymore

and

Re: Create Indesign.Application CC

HTH

Trevor

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
Guide ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

this is not VB.

Your code is VB, it creates a String of the file name.

then using DoScript.javascript you are passing the string to the Javascript engine.

Escape them as stated by Loic.Aigon​

"D:\\Program Files (x86)\\Adobe\\Adobe InDesign CC 2015\\Scripts\\Scripts Panel\\Test.jsx"

or revers them

"D:/Program Files (x86)/Adobe/Adobe InDesign CC 2015/Scripts/Scripts Panel/Test.jsx"

both will work.

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
Guide ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

also:

Set myInDesign = CreateObject("InDesign.Application.CC2015")

should be

Set myInDesign = CreateObject("InDesign.Application.CC.2015")

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
Guru ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Sorry Loic,

I should of spotted the "myJavaScript, 1246973031" part.

Trevor

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
Guru ,
Mar 09, 2017 Mar 09, 2017

Copy link to clipboard

Copied

Nope, I'm not sorry.

I just tested it. In this case the myJavaScript is not javascript it is the path to the javascript so it need not be escaped.

However escaping it does not cause harm neither does using / instead of \.

In summary all 3 methods work here.

Trevor

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
Participant ,
Mar 10, 2017 Mar 10, 2017

Copy link to clipboard

Copied

Hi All,

Thanks for reply. I tried all possibilities but the error comes as follows. I am new to VB script. help me.

error.jpeg

My task is in windows system to execute InDesign javascript file in script panel from outside of the InDesign as applescript does as below.

But the applescript not execute in windows system so I tried in VB script.

AppleScript code

~~~~~~~~~~~~~

set aScriptPath to "Applications:Adobe InDesign CC 2015:Scripts:Scripts Panel:Test:Test.jsxbin"

set pScriptPath to POSIX path of aScriptPath --"/Applications/Adobe InDesign CC 2015/Scripts/Scripts Panel/Test/Test.jsxbin"

tell application "Adobe InDesign CS6"

  Activate

  do script alias aScriptPath language javascript

end tell

Please help me.

Thanks in Advance,

Mahesh

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
Guru ,
Mar 12, 2017 Mar 12, 2017

Copy link to clipboard

Copied

Hi there,

Here's a working example:

Set myInDesign = CreateObject("InDesign.Application.CC.2017")

myJavaScript = "C:\Program Files\Adobe\Adobe InDesign CC 2017\Scripts\Scripts Panel\Test.jsxbin"

myInDesign.DoScript myJavaScript, idScriptLanguage.idJavascript

Also, you can reference the application without specifying the version like so:

Set myInDesign = CreateObject("InDesign.Application")

The JavaScript is the one-liner:

alert("Hello from JavaScript", "JavaScript message", false);

I get it called from VBS:

12-03-2017 17-30-00.png

Hope this helps.

— Kas

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
Guide ,
Mar 13, 2017 Mar 13, 2017

Copy link to clipboard

Copied

My turn to say sorry,

I miss read and saw DoScript.javascript, not DoScript myJavaScript.

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
Guru ,
Mar 12, 2017 Mar 12, 2017

Copy link to clipboard

Copied

Here's a more elegant solution: both scripts should be located in the same folder -- JS and VBS. The latter uses the ActiveScript property to figure out the path to the folder with the scripts.

Set myInDesign = CreateObject("InDesign.Application.CC.2017")

Set myFSO = CreateObject("Scripting.FileSystemObject")

myActiveScript = myInDesign.ActiveScript

Set myFile = myFSO.GetFile(myActiveScript)

myJavaScriptFileName = "Test.jsxbin"

myJavaScriptFilePath = myFile.ParentFolder.Path & "\" & myJavaScriptFileName

myInDesign.DoScript myJavaScriptFilePath , idScriptLanguage.idJavascript

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
Guru ,
Mar 12, 2017 Mar 12, 2017

Copy link to clipboard

Copied

Looks like there's something wrong with the path Mahesh is using.

Try

pathToMyFile = "C:\Path\to\the\file" ' change to the correct path

Msgbox("VB says - File exists: " & CreateObject("Scripting.FileSystemObject").FileExists(pathToMyFile))

CreateObject("InDesign.Application.CC.2015").DoScript "alert(""Hi From InDesign"")", 1246973031

If the path is false then you know your problems nothing to do with ID

If you get "Hi From InDesign" then you know you are communicating good with ID

If the problems with the path then try with a more simple path like "C:\myJavaScript.jsx" and see if that works.

HTH

Trevor

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
Guru ,
Mar 17, 2017 Mar 17, 2017

Copy link to clipboard

Copied

LATEST

Did you not get this working?

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