Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:25:31+00:00 2026-06-08T06:25:31+00:00

I am using the method   myFile.execute()   to open an InDesign document programmatically

  • 0

I am using the method  myFile.execute()  to open an InDesign document programmatically (in this case, it is a blank document with styles applied to it).


The document is sometimes opened, and at other times it is not… It seems as if the script does not have enough time to open the file before it is done.


This occurred to me because upon testing with  alert(template.name)  it does show the file name I’m looking for, and the script does not throw an error when applying  File(template).execute()  (the variable  template  is itself already a  File  object, but simply  template.execute()  is not working either).


Here is the relevant code:

function openStylesTemplate()
{
    var templateFolder = getScriptFolder(); // with the function below
    var fileArray = templateFolder.getFiles("*.indd"); // an array of all InDesign documents in this script's same folder

    try
    {
        var template = fileArray[0]; // the ONLY InDesign document in the folder
        File(template).execute(); // open the InDesign template document
    }
    catch(e)
    {
        alert("Error: " + e.message + "\n\n" +
                 "Make sure the InDesign styles document is in the same folder as this script,\n" +
                  "and that it is the ONLY InDesign document in this folder, and try again.\n\n" +
                 "This script is in this folder: " + templateFolder + ".");

        exit();
     }
} // end of function openStylesTemplate

So, could the script possibly not have enough time to load the document? If so, should I create a timer before this function is called? Or is there a better way to open an InDesign document programmatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:25:33+00:00Added an answer on June 8, 2026 at 6:25 am

    Opening an indesign document isn’t matter of File.execute() which simply opens a file from the os point of view without any reference to the file itself. You do open files by calling app.open ( file );.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when using this method public List<Field> getFieldWithoutId(List<Integer> idSections) throws Exception { try { Connection
I am using this method on a button click. My app is not yet
I have VB.NET code in Visual Studio 2008 using an obsolete method and would like to
This is my Method: Datatable data2 = new Datatable(); int result = 0; using
I'm building graph using method IGraphBuilder::RenderFile And query interfaces IMediaControl - to run video
When loading the class, using method forName() , any static initializers in the class
When programming against a fluent API or just using method-chaining, I've seen the style
Using the method from Steve Sanderson's blog , I have a list of items
Using the method presented here: http://cslibrary.stanford.edu/110/BinaryTrees.html#java 12. countTrees() Solution (Java) /** For the key
Using java I am trying to develop a method using recursion to analyze a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.