Adding section break via macro
Page 1 of 1

Author:  xiamenese [ 2013-07-03 18:20:04 ]
Post subject:  Adding section break via macro

I am trying to create a macro which will take a string in a file exported from Scrivener:

and replace it with a <Section Break : Next Page>.

When I use Find and Replace, enter the appropriate string in the Find box and put the appropriate command from the menu in the Replace box,
Nisus Writer ProScreenSnapz001.jpg
Nisus Writer ProScreenSnapz001.jpg [ 46.72 KiB | Viewed 3156 times ]

then click "Replace All" it does just what I want.

If I choose "Macroize", it puts the following commands into the macro — copying it to the clipboard reveals this:

Find and Replace '‡‡‡‡‡
', ' ', 'aU'

When I run that, what I get is <Section Break [No page break]> Can someone tell me how can I make it so that the Macro gives me a page break.


Author:  martin [ 2013-07-03 23:09:21 ]
Post subject:  Re: Adding section break via macro

Offhand I'm not sure why the macroized version isn't working. It probably has something to do with the way section break characters rely on a hidden attribute to enforce their next page, same page, odd page, etc, status. We'll have to take a look.

In the meantime, the most direct workaround is something like this:
$findWhat = '‡‡‡‡‡

Select Document Start
While Find Next $findWhat
   Menu 'Insert:Section Break:Next Page'

Author:  Groucho [ 2013-07-04 05:50:39 ]
Post subject:  Re: Adding section break via macro

Hello, Mark.

I wrote this macro years ago. It still works nicely. Last time I used it was yesterday. You can substitute any kind of section break for any placeholder text. Just run it.

Greetings, Henry.

Split into Sections.nwm [31.5 KiB]
Downloaded 204 times

Author:  martin [ 2013-07-05 13:30:25 ]
Post subject:  Re: Adding section break via macro

That's a handy macro Henry, thanks for sharing it.

One irrelevant improvement you could make to reduce the code is changing this:
While Find $tag, 'E'
   if $break == "Next Page"
   Insert:Section Break:Next Page
   elsif $break == "Odd Page"
   Insert:Section Break:Odd Page
   elsif $break == "Even Page"
   Insert:Section Break:Even Page
   elsif $break == "Same Page"
   Insert:Section Break:Same Page

To construct the menu path directly using the user's chosen section break type name:
$menuPath = "Insert:Section Break:$break"
While Find $tag, 'E'
   Menu $menuPath

Author:  Groucho [ 2013-07-05 21:43:04 ]
Post subject:  Re: Adding section break via macro

Great help, Martin, thanks. About the menu path, that was something I tried to do but I lacked the skills. I will change the macro.

Greetings, Henry.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group