🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
5 messages
5 total messages Started by hm24_arul Tue, 10 Mar 2009 14:07
Close all documents
#616
Author: hm24_arul
Date: Tue, 10 Mar 2009 14:07
24 lines
1257 bytes
Hi scripters,

I have 15 documents open in my indesign application. I am trying to close all the documents. Please see my code below

if(app.documents.length!=0)
{
for (i=0; i<app.documents.length; i++) { app.documents.item(i).close(SaveOptions.no); }	 	} else {null;}

if(app.documents.length!=0)
{
alert('All documents are closed')
}
else
{
alert('Still documents are opened')	
	}
It works good but, not all the documents are closed, before getting the app.documents.length=0 the alert box is popping. And still some documents are opened.

Please advice me how can I close all the documents?

thanks in advance

regards
a r u l
Re: Close all documents
#617
Author: xbytor
Date: Tue, 10 Mar 2009 14:13
3 lines
811 bytes
Loop through the array backwards if you are removing elements from it.

> for (var i=app.documents.length-1; i >= 0; i--) { app.documents[i].close(SaveOptions.no); }
Re: Close all documents
#619
Author: Robert Tkaczyk
Date: Tue, 10 Mar 2009 14:31
12 lines
1033 bytes
... or if you want to close/delete all objects from collection - close/delete last object until there is no objects ;)

VB example:

do while myInDesign.Documents.Count
   call myInDesign.Documents.Item(-1).Close(idSaveOptions.idNo)
loop

robin

-- 
www.adobescripts.com
Re: Close all documents
#620
Author: hm24_arul
Date: Tue, 10 Mar 2009 14:32
8 lines
784 bytes
Hi xbytor

thanks it works, I am sure hereafter i will be careful in loop commands.

once again thanks a lot

regards
a r u l
Re: Close all documents
#626
Author: Olav_Kvern
Date: Tue, 10 Mar 2009 15:51
7 lines
711 bytes
Hi a r u l,

You could also take a look at the CloseAll.jsx script that's provided with (and shown in) the Scripting Guide.

Thanks,

Ole
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads