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]
1 Correct answer
Try this,
myTestJavaScript = "C:\Program Files\Adobe\Adobe InDesign CC 2017\Scripts\Scripts Panel\test.jsx";
myInDesign.DoScript myTestJavaScript
Regards
Sunil
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
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
Copy link to clipboard
Copied
Yeah, that was my bad, I forgot to mention that..
Copy link to clipboard
Copied
instead of the number constant you can also use
idScriptLanguage.idJavascript
Copy link to clipboard
Copied
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

