Loop through open documents

Get help using and writing Nisus Writer Pro macros.
Post Reply
tedg
Posts: 42
Joined: 2012-09-22 01:52:56
Location: Brisbane, Australia
Contact:

Loop through open documents

Post by tedg »

I have a nice macro that sets various view parameters of an open document. How do I apply that to all open documents?

Things like no pallets, window size and position, typewriter scrolling. Nothing in the doc content.

TiA, Ted
User since 1990
Most current NWp and MacOS
MacBookPro 16-inch 2021
adryan
Posts: 561
Joined: 2014-02-08 12:57:03
Location: Australia

Re: Loop through open documents

Post by adryan »

G'day, Ted et al

Regular visitors will know that I have only rudimentary knowledge of the Nisus Macro Language, but I felt sure the answer would lie in at least one of the supplied Macros. And indeed there is a snippet of code for looping through all open documents in the Macro titled "Save All Documents" in the Document set of Macros that you may find helpful. It uses the Document Type Command "Document.openDocuments". It is also used in the Macro titled "Sort Open Document Windows" in the same location, so you know it must be good.

Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
tedg
Posts: 42
Joined: 2012-09-22 01:52:56
Location: Brisbane, Australia
Contact:

Re: Loop through open documents

Post by tedg »

Fantastic. Thanks
User since 1990
Most current NWp and MacOS
MacBookPro 16-inch 2021
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Loop through open documents

Post by phspaelti »

As Adrian says Document.openDocuments should work. The following code will apply My Fantastic Macro to all open documents.

Code: Select all

foreach $doc in Document.openDocuments
Document.setActive $doc
My Fantastic Macro
end
philip
Post Reply