Page 1 of 1
Change the Normal Style via Macro
Posted: 2023-06-21 19:53:40
by loulesko
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
Re: Change the Normal Style via Macro
Posted: 2023-06-21 21:48:54
by adryan
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
Re: Change the Normal Style via Macro
Posted: 2023-06-22 03:05:40
by phspaelti
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:
Code: Select all
$doc = Document.active
$styleSample = 'Example'
$doc.addStyles $styleSample, 'replace'
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
Re: Change the Normal Style via Macro
Posted: 2023-06-22 07:03:04
by loulesko
Philip,
Many thanks for the details.
Lou
Re: Change the Normal Style via Macro
Posted: 2023-06-26 08:40:46
by martin
loulesko wrote: ↑2023-06-21 19:53:40
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.
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"
I hope that helps!
Re: Change the Normal Style via Macro
Posted: 2023-06-26 10:14:29
by loulesko
Martin
Many thanks. This is super helpful. Bit of an experiment for workflow from Nisus to Google Docs for a book project.
-Lou