This content has been marked as final. Show 10 replies
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);
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?
Which documentation where?
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.
Could you give me a page reference? Or better yet quote the text that led you astray?
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.
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.
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.
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...
myIndesign = new ActiveXObject("IndesignServer.Application.CS3");
var myDocument = myIndesign.open("E:\test\tagged.indd", false);
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.