nisus.com
https://www.nisus.com/forum/

Close all closes Document Manager Too?
https://www.nisus.com/forum/viewtopic.php?f=17&t=4001
Page 1 of 1

Author:  Groucho [ 2010-12-03 11:07:25 ]
Post subject:  Close all closes Document Manager Too?

I wrote this macro some time ago (it is for converting any document into pdf):
Code:
# Save all open documents.

Require Application Version 3.1


Prompt 'This macro opens and converts documents into pdf. Any open document will be closed first. Pdfs are saved in the same folder as the original and with the same name.'



File:Close All # first close all open documents
File:Open… # then open new ones

# loop through all open documents
$allDocs = Document.openDocuments
ForEach $doc in $allDocs
   Document.setActive($doc)
   Save as PDF...
   Press Default Button
   Close
end

Is there a way to tell NWP to close all open documents but not the Document Manager?

Author:  martin [ 2010-12-03 12:26:15 ]
Post subject:  Re: Close all closes Document Manager Too?

Not with a single command, but you can do it with a loop:
Code:
$allDocs = Document.openDocuments
ForEach $doc in $allDocs
   $doc.close
End

Author:  Groucho [ 2010-12-04 02:25:18 ]
Post subject:  Re: Close all closes Document Manager Too?

Where there’s a loop there’s a way. Thank you, Martin.

Henry

Author:  Kino [ 2011-01-17 09:23:29 ]
Post subject:  Re: Close all closes Document Manager Too?

Groucho’s macro wrote:
Any open document will be closed first.
Your macro seems to close all open documents for the sole purpose of preventing them from being saved as PDF together with those which are going to be opened. So do I think but I may be wrong. Perhaps it makes you happy, very happy, very very happy to see the Document Manager window with no document window, perhaps. Chacun son goût. Anyway, in such a situation, if you use Choose Files command instead of Open… (menu command) to select files, you don’t need closing any document, for newly opened ones are identified by their file paths ($path[s]) and then by a Document object ($doc) returned by Document.open $path.
Code:
$paths = Choose Files '', 'Make PDF'

if $paths == undefined
   exit  # Cancelled by the user
end

foreach $path in $paths
   $doc = Document.open $path
   $pdfPath = $path.filePathByChangingExtension 'pdf'
   Document.setActive $doc  # make sure that $doc is the frontmost
   Save As PDF $pdfPath
   $doc.close true  # true [= discard changes] is very unlikely to be useful here, though
end

Author:  Groucho [ 2011-01-17 11:08:42 ]
Post subject:  Re: Close all closes Document Manager Too?

Quote:
At first Kino was saying:
Your macro seems to close all open documents for the sole purpose of preventing them from being saved as PDF together with those which are going to be opened. So do I think but I may be wrong.

No, you are right, Kino. I like to keep the Document Manager always open.

Quote:
Then he went on like this…
Anyway, in such a situation, if you use Choose Files command instead of Open…

Grand. I had thought of using Choose Files but I was at a loss how to develop a macro that way. Until you came to rescue. Thank you, Kino.

Henry.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/