Skip to main content
Participating Frequently
July 26, 2011
Answered

Cannot Open .indd template file

  • July 26, 2011
  • 2 replies
  • 2828 views

Hi,

I have some javascript code that I am porting from CS3 to CS5.

The code was working well on a Windows Server as CS3.

I have ported this to run fine on my local Mac machine on CS5.

As soon as I try to run this on a Mac Server running CS5 I get issues.

Here is the original code snippet.

template = File("/myDirectory/sample_template.indd");

document = app.open(template, true);

The file exists and template.exists is combing back as 'true'.

The error logging coming back is this:

Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.

I have tried the following code variations with the following results in red.

document = app.open(template);
Error: Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE., Invalid value for parameter 'openOption' of method 'open'. Expected OpenOptions enumerator, but received TRUE.

document = app.open(template, OpenOptions.OPEN_ORIGINAL);
Error: defaultValue is undefined, defaultValue is undefined

document = app.open(template, OpenOptions.openOriginal);
Error: defaultValue is undefined, defaultValue is undefined

document = app.open(template, OpenOptions.openCopy);
Error: defaultValue is undefined, defaultValue is undefined


I am running this as CS5 (app.scriptPreferences.version = 7;)

Any ideas why app.open() is failing?

Carlos

This topic has been closed for replies.
Correct answer John Hawkinson

The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.

Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.

2 replies

John Hawkinson
John HawkinsonCorrect answer
Inspiring
July 27, 2011

The arguments to app.open() are different under InDesign server. See: http://jongware.mit.edu/idcs5serv_html_3.0.3d/idservcs5/pc_Application.html#open.

Unsurprisingly, the showingWindow option is omitted, because InDesign Server never shows windows.

Participating Frequently
July 28, 2011

So the general solution which works for me is to check for Server vs Desktop

and use the appropriate parameter list. Something like this:

   if (isInDesignServer == true)
    {
        document = app.open(template, OpenOptions.OPEN_COPY);
    }
    else
    {

        var showWindow = false;
        document =  app.open(template,  showWindow);
    }

thanks guys.

John Hawkinson
Inspiring
July 28, 2011

It seems like there should be a better way but I don't see one.

I suppose while this could conceivably be a design error, trying

to fix it in the next version doesn't seem like a good idea either,

so there's really nothing we could ask Adobe to do to improve the

situation, right?

milligramme
Inspiring
July 27, 2011

Hi

You should not omit ShowingWindow in CS5 when use OpenOptions.

"document = app.open(template)" must be used default value to options, why Error?

CS3

app.open(from, [showingWindow])

document = app.open(template);

document = app.open(template, true);

CS5

app.open(from, [showingWindow], [openOption])

document = app.open(template);

document = app.open(template, true);

document = app.open(template, true, OpenOptions.OPEN_ORIGINAL);

document = app.open(template, true, OpenOptions.OPEN_COPY);

Did you try .indt (InDesign Template File)?
Thankyou
mg.