Page 1 of 1
Adding section break via macro
Posted: 2013-07-03 18:20:04
by xiamenese
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 (46.72 KiB) Viewed 10307 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:
Code: Select all
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.
Thanks
Mark
Re: Adding section break via macro
Posted: 2013-07-03 23:09:21
by martin
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:
Code: Select all
$findWhat = '‡‡‡‡‡
'
Select Document Start
While Find Next $findWhat
Menu 'Insert:Section Break:Next Page'
End
Re: Adding section break via macro
Posted: 2013-07-04 05:50:39
by Groucho
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.
Re: Adding section break via macro
Posted: 2013-07-05 13:30:25
by martin
That's a handy macro Henry, thanks for sharing it.
One irrelevant improvement you could make to reduce the code is changing this:
Code: Select all
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
end
end
To construct the menu path directly using the user's chosen section break type name:
Code: Select all
$menuPath = "Insert:Section Break:$break"
While Find $tag, 'E'
Menu $menuPath
end
Re: Adding section break via macro
Posted: 2013-07-05 21:43:04
by Groucho
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.