Search code examples
windowsvbscriptautomationjsxadobe-indesign

InDesign Automated Tests


Is there a way to create automated tests for InDesign in Windows? For example:

  • Open InDesign
  • Open a Document
  • Run a JSX Script
  • Close file
  • Close InDesign

From what I've researched I didn't find an straight forward way to do it. What I found was a mix of languages. VBScript with JSX. I had this with AppleScript instead of VBScript but it was messy. It could crash at any moment without an easy way of recover it.


Solution

  • I was able to create an automated test using C#. Before I start I needed to do a couple of steps in order to have a good environment to develop.

    This is the setup I used:

    • Windows 10 Pro
    • Visual Studio 2017 Pro (Trial)
    • InDesign CC 2017

    Now the steps of how I did it:

    • Start InDesign as admin to create a file so I could use as reference in my Visual Studio Project
    • Create a new Console project (This was my case)
    • Add the COM Reference to the project. In the tab COM, you will find a reference to an Indesign tlb file COM References

    Now to create an Indesign instance I used the following code:

    Type inDesignAppType = Type.GetTypeFromProgID("InDesign.Application.CC.2017");
    InDesign.Application myInDesign = (InDesign.Application)Activator.CreateInstance(inDesignAppType);
    

    After this, to run an InDesign script I used:

    String myString = myInDesign.DoScript("return \"My String\"", InDesign.idScriptLanguage.idJavascript, new object[] {""});
    

    I hope my solution helps someone else.