Macro command to Import from Style Library…

Get help using and writing Nisus Writer Pro macros.
Post Reply
vwnisus
Posts: 36
Joined: 2016-04-24 00:13:31

Macro command to Import from Style Library…

Post by vwnisus » 2018-10-25 02:13:21

I am new to Nisus Writer Pro Macros (upgraded to version 3.0).

I need open rtf files provided to me and wish to then carry out some formatting to which I wish to apply some styles which I have saved in style library.

Is there a macro command to import a specific style collection from the style library?

Use the menu command method does not appear to work here.

Any help gratefully received.

User avatar
phspaelti
Posts: 1043
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro command to Import from Style Library…

Post by phspaelti » 2018-10-25 04:10:44

Hello vw,
there is no specific command to import styles. The macro language has a command to add styles to a document though. You'll need the document object. So it looks like this:

Code: Select all

$doc = Document.active
$doc.addStyles $myStyle
This command can also take an argument to tell it what to do in case of a style conflict. For example "replace" will override the conflict.

So you can get styles from your Style Library by opening the desired Style Library Document, getting the styles you want, and then adding them to the other document. The whole will look something like this:

Code: Select all

$editDoc = Document.active
$styleLibDoc = Document.open "style/library/file/path"
$editDoc.addStyles $styleLibDoc.allStyles, "replace"
$styleLibDoc.close
philip

vwnisus
Posts: 36
Joined: 2016-04-24 00:13:31

Re: Macro command to Import from Style Library…

Post by vwnisus » 2018-11-02 05:15:10

Philip,

Thank you for providing working code. I was able to implement it successfully (although I can understand how individual element work, but how you constructed the macro is beyond me).

My final macro:

Code: Select all

$editDoc = Document.active
$styleLibDoc = Document.open "/Users/victor/Dropbox/Nisus/Nisus Writer Settings/Style Library/LexisNexis Case Formatting.rtf"
$editDoc.addStyles $styleLibDoc.allStyles, "replace"
$styleLibDoc.close
Set Zoom 200
Select All
Format:Paragraph Style:LexisNexis

Format:Text Color:Black

Find and Replace ‘\n\n+’, ‘\n’, ‘Eas’

Save

Sleep 2

Close Window

Post Reply