Hi,
I'm learning to write macros by coping and editing existing files. But now I don't know how to proceed. How can I insert commands in my macro which I usually carry out by mouse?
For example "Select All > Format > Parapgraph Styles > Remove style"
Thanks for every help,
Elisa
Insert commands in macro
Re: Insert commands in macro
Welcome to the forum!It is not necessary to use the syntax Menu '<menu path>'. Just <menu path> works. So you can reduce the macro to . . .In my understanding, the former (Menu '<menu path>') is faster, but I’m too lazy to try a benchmark test.
Also, if the last component of a menu path is unique, you can simplify the macro into something likeHowever, Select All Style and Remove Style exist not only under :Format:Paragraph Style but also under :Format:Character Style. So there is no guarantee that commands under the former will be preferred — by NWP — over those under the former. So was I told (perhaps in a dream, ;-) but I have never verified it. Perhaps the physical position/order of homonymous menu commands does matter? Again, I’m too lazy.
You can write a macro just by listing menu commands (or menu command paths) in the right order. I think you mean “Select All” in Paragraph Style menu in the status bar. Unfortunately there is no means to call such a command in a macro but its menu command equivalent does exist. So your macro would be . . .Elisa wrote:For example "Select All > Format > Parapgraph Styles > Remove style"
Code: Select all
Menu ':Format:Paragraph Style:Select All Style'
Menu ':Format:Paragraph Style:Remove Style'
Code: Select all
:Format:Paragraph Style:Select All Style
:Format:Paragraph Style:Remove Style
Also, if the last component of a menu path is unique, you can simplify the macro into something like
Code: Select all
Select All Style
Remove Style
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re: Insert commands in macro
Kino has the right of it, despite his laziness But truthfully Kino is decidedly dedicated and a hard worker, especially when it comes to helping our users with macros.
Some comments:
You may notice that a menu path fragment is not preceded by a ":"- an initial colon is only used if the path is full/complete.
Some comments:
It's unlikely there's much of a speed difference between using the command "Menu" and just using the menu path directly. Personally I prefer the former because it's clearer, but either form works just as well.Kino wrote:Just <menu path> works. So you can reduce the macro to . . .In my understanding, the former (Menu '<menu path>') is faster, but I’m too lazy to try a benchmark test.Code: Select all
:Format:Paragraph Style:Select All Style :Format:Paragraph Style:Remove Style
If the menu name is not unique, then the menu Nisus Writer will choose is undefined. One should not rely on any behavior, even if there appears to some consistent rule with respect to how the menus are ordered/positioned. It's best to simply use a full menu path, or if brevity is preferred a path fragment, like:Also, if the last component of a menu path is unique, you can simplify the macro into something likeHowever, Select All Style and Remove Style exist not only under :Format:Paragraph Style but also under :Format:Character Style. So there is no guarantee that commands under the former will be preferred — by NWP — over those under the former. So was I told (perhaps in a dream, ;-) but I have never verified it. Perhaps the physical position/order of homonymous menu commands does matter?Code: Select all
Select All Style Remove Style
Code: Select all
Menu 'Character Style:Select All Style'
Re: Insert commands in macro
Kino and Martin, you are great!
Thank you so much for your advices. They are very helpfull!
Elisa
Thank you so much for your advices. They are very helpfull!
Elisa