Hello all,
Wondering if anyone can point me in the right direction to create macro which will change the font of the Normal paragraph style in a document.
Many thanks,
Lou
Change the Normal Style via Macro
Re: Change the Normal Style via Macro
G'day, Lou et al
Why not just change it in the Style Sheet?
Alternatively, as long as the cursor is situated within a paragraph with Normal Style (because that's the one you want to change), you could invoke a simple Macro with the following two lines (with your choice of font):–
Format:Paragraph Style:Select All in Style
Format:Font:All Fonts:Apple Chancery
Cheers,
Adrian
Why not just change it in the Style Sheet?
Alternatively, as long as the cursor is situated within a paragraph with Normal Style (because that's the one you want to change), you could invoke a simple Macro with the following two lines (with your choice of font):–
Format:Paragraph Style:Select All in Style
Format:Font:All Fonts:Apple Chancery
Cheers,
Adrian
MacBook Pro (M1 Pro, 2021)
macOS Ventura
Nisus Writer user since 1996
macOS Ventura
Nisus Writer user since 1996
Re: Change the Normal Style via Macro
Hi Lou,
The simplest way to do this is in a macro is to paste a sample that contains the relevant style. The macro language has a special command for this, and so the following code will do this:
Note that for this code to work $styleSample will need to have the relevant style applied, so you will need to paste it into your macro. If your macro already has a different Normal style, you will need to delete it from the macro or rename it.
Alternatively you can collect a sample from some other file and transfer it to the target document using this type of code.
HTH
Philip
The simplest way to do this is in a macro is to paste a sample that contains the relevant style. The macro language has a special command for this, and so the following code will do this:
Code: Select all
$doc = Document.active
$styleSample = 'Example'
$doc.addStyles $styleSample, 'replace'
Alternatively you can collect a sample from some other file and transfer it to the target document using this type of code.
HTH
Philip
philip
Re: Change the Normal Style via Macro
Philip,
Many thanks for the details.
Lou
Many thanks for the details.
Lou
- martin
- Official Nisus Person
- Posts: 5230
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Change the Normal Style via Macro
As usual there's a few different ways you could come at this, depending on your exact situation. But here's what's probably the most general purpose macro solution:
Code: Select all
# select the style to modify
$doc = Document.active
$style = $doc.styleWithName("Normal")
Style.setStyleViewEditingStyles(Array.new($style))
# apply desired formatting
Menu "Format:Font:All Fonts:Arial"
# return to normal document mode
Menu "View:Draft View"
Re: Change the Normal Style via Macro
Martin
Many thanks. This is super helpful. Bit of an experiment for workflow from Nisus to Google Docs for a book project.
-Lou
Many thanks. This is super helpful. Bit of an experiment for workflow from Nisus to Google Docs for a book project.
-Lou