Skip to main content
Known Participant
January 27, 2009
Question

Open Dialog doesn't open files

  • January 27, 2009
  • 10 replies
  • 961 views
I am using the following to browse for multiple files to open.
var myFileMain = File.openDialog ("Select a file", "Documents:*.indd",false);

However, when I add this line to display the files I get the error "undefined, not an object"
var myLayoutWindow = myDocument.windows.add();

I have even just copied the snippet from the Official Scripting Guide to see if I was causing the error with my first line but I get the same error here for the second line.
var myDocument = app.open(File("/c/myTestDocument.indd"), false);
var myLayoutWindow = myDocument.windows.add();

So I tried switching the first line to true instead of false but then in testing in Indesign I get the message that no documents are open.

Can anyone point out what I am doing wrong?
This topic has been closed for replies.

10 replies

Known Participant
February 2, 2009
Hi Wim,

You should start a new topic, because your message has nothing to do with the thread you've posted it in.

To create an instance of InDesign server, use CreateObject, as shown in all of the example scripts.

Thanks,

Ole
Participant
February 2, 2009
Hello,

CAn somebody help me?

I'm trying to open a file with the code below, but I get a security error (no access to the file) Please tell me what is wrong...

Code:
myIndesign = new ActiveXObject("IndesignServer.Application.CS3");
var myDocument = myIndesign.open("E:\test\tagged.indd", false);

Thanks,

Wim
Inspiring
January 28, 2009
You either didn't understand or didn't read the example well enough. You have to open the document before you can display a window. Your original code located the document file but didn't open it.

Dave
_mps_Author
Known Participant
January 28, 2009
Hi Dave & Olav,

First to Dave; quote is below. From page 12.
You can choose to prevent the document from displaying (i.e., hide it) by setting the showing window
parameter of the open method to false (the default is true). You might want to do this to improve
performance of a script. To show a hidden document, create a new window, as shown in the following
script fragment (from the OpenDocumentInBackground tutorial script):
//Opens an existing document in the background, then shows the document."
//Youll have to fill in your own file path."
var myDocument = app.open(File("/c/myTestDocument.indd"), false);"
//At this point, you could do things with the document without showing the"
//document window. In some cases, scripts will run faster when the document"
//window is not visible."
//When you want to show the hidden document, create a new window."
var myLayoutWindow = myDocument.windows.add();

Second for Olav,
In actuality I changed the "myTestDocument.indd" to an actual file and I did try changing the false to true (didn't try omit even though I know that it will default to true).

The error message occurs when the next line executes. Error "No Documents are open". The snippet Dave gave above fixed the problem, but it would seem from the documentation that the above solution should work as well.

I hope this is clear enough. Not really a big deal for me at this point since Dave's solution worked, just wanted to know if I was missing something major in interpretation.

Thank you both for your time and expertise.
Known Participant
January 28, 2009
Hi Matt,

re: "I have even just copied the snippet from the Official Scripting Guide to see if I was causing the error with my first line but I get the same error here for the second line.
var myDocument = app.open(File("/c/myTestDocument.indd"), false);
var myLayoutWindow = myDocument.windows.add();"

The first question--do you have a file named "myTestDocument.indd" on a drive named "c"?

The second parameter controls whether the document opens with a visible window or not. If you omit it or change it to true, you don't need the line that creates a new window.

Thanks,

Ole
Inspiring
January 28, 2009
Could you give me a page reference? Or better yet quote the text that led you astray?

Dave
_mps_Author
Known Participant
January 28, 2009
Sorry I wasn't clear.

InDesignCS3_ScriptingGuide_JS.pdf from Adobe.

I'm using the CS3 version since that is the version of ID I have.

Thanks again,
Matt
Inspiring
January 28, 2009
Which documentation where?

Dave
_mps_Author
Known Participant
January 27, 2009
Thank Dave, you've been a great help again.

One question; any idea why the documentation states to add a window rather than this function?
Inspiring
January 27, 2009
The open dialog returns a file object that you must open:

var myFileMain = File.openDialog ("Select a file", "Documents:*.indd",false);
var myDocument = app.open(myFileMain);

Dave