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

Call JSX-Scripts from the InDesign Script Panel from within VBA?

New Here ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

Hi there

Let’s say I have written a "test.jsx" (located at C:\Users\Username\AppData\Roaming\Adobe\InDesign\Version 13.0\de_DE\Scripts\Scripts Panel\):

var myDocument = app.documents.item(0);

var myTextFrame = myDocument.textFrames.add();

myTextFrame.geometricBounds = ["20mm", "20mm", "100mm", "100mm"];

myTextFrame.contents = "Hello World";

I also have an Excel document "test.xlsm" containing a button. This button calls my VBA macro. This macro opens InDesign and „test.indd“ (like the excel doc located at C:\Users\Username\Documents\):

Sub sayHelloToWorld()

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

     myInDesign.Activate

     myInDesign.Open (ThisWorkbook.Path & "\test.indd")

End Sub

Here I’m struggling to find a way to tell InDesign to run "test.jsx". Something like this:

myInDesign.DoScript(„test.jsx“)

My goal is to just click on the button in my Excel document, the InDesign document would open and print „Hello World“. I want my JS script in a separated jsx file if that’s possible and I don’t want to run test.jsx as a startup script. I would prefer a pure VBA solution as I'm completely unexperienced with shell scripting.

I added the InDesign Reference like described in https://forums.adobe.com/thread/2194605 but I don’t even know what that’s good for. It seems to me that it is possible in Apple Script (https://forums.adobe.com/thread/2209803) but I don’t manage to translate that into VBA.

Using Windows 10 Pro (10.0.17134), InDesign 13.1 x64, Excel 14.0.7212.5000 (32-bit)  [Office 2010]

TOPICS
Scripting

Views

1.2K

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

correct answers 1 Correct answer

Advocate , Sep 09, 2018 Sep 09, 2018

Try this,

myTestJavaScript = "C:\Program Files\Adobe\Adobe InDesign CC 2017\Scripts\Scripts Panel\test.jsx";

myInDesign.DoScript myTestJavaScript

Regards

Sunil

Votes

Translate

Translate
Advocate ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

Try this,

myTestJavaScript = "C:\Program Files\Adobe\Adobe InDesign CC 2017\Scripts\Scripts Panel\test.jsx";

myInDesign.DoScript myTestJavaScript

Regards

Sunil

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 ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

You need to specify the type of the script that is being called up. So the code should be as follows

myInDesign.DoScript "test.jsx", 1246973031

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
Advocate ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

Yeah, that was my bad, I forgot to mention that..

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 ,
Sep 09, 2018 Sep 09, 2018

Copy link to clipboard

Copied

instead of the number constant you can also use

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
New Here ,
Sep 10, 2018 Sep 10, 2018

Copy link to clipboard

Copied

LATEST

Oh yes, that works:

myTestJavaScript = "C:\Users\Username\AppData\Roaming\Adobe\InDesign\Version 13.0\de_DE\Scripts\Scripts Panel\test.jsx"

myInDesign.DoScript myTestJavaScript, idScriptLanguage.idJavascript

So it was just the missing braces which took me hours. Thank you both very much for answering this, helped me a lot

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