Save for Word Macro

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
scottwhitlock
Posts: 174
Joined: 2004-10-26 07:10:40
Location: Tucson, AZ
Contact:

Save for Word Macro

Post by scottwhitlock » 2007-07-30 21:19:25

Hello all,

As I'm no programmer, I need help writing a macro. Some of my styles do not translate well when opening an rtf in Word, so I would like to create a Save for Word macro that does the following...
  • Finds all of one style and replaces with another (if no style instance found, ignore and move to next command)

    Finds all of another style and replaces with another (once again, if no style instance found, ignore and move to next command)

    Turns off Allow Hyphenation

    Saves a document as original filename without extension with (for Word) appended
For example:
  • Find All Paragraph Style H1 Sans Bold xS and Change All to Word - H1 Sans Bold (if none, ignore and move to next command)

    Find All Paragraph Style H1 Serif Bold xS and Change All to Word - H1 Serif Bold (if none, ignore and move to next command)

    Turn off Allow Hyphenation (if already off, ignore)

    Save in Document Manager with original filename with “(for Word)” appended at end
Any help will be greatly appreciated and rewarded with good karma...:)

Thanks,

Scott
MacBook Pro 15
2.66 Ghz Core i7
8GB RAM
10.8.3
NWP 2.0.4
iPad 3

User avatar
martin
Official Nisus Person
Posts: 4361
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin » 2007-07-31 17:48:52

Well, if there's karma involved, here's a macro. It basically uses an attribute sensitive Find All and then applies the new style.

One thing to note: this macro does not turn off hyphenation. Currently you can't do that, you can only toggle it. If you mostly work with hyphenation on, perhaps you should add the following line to the macro:

Menu 'Allow Hyphenation'

User avatar
scottwhitlock
Posts: 174
Joined: 2004-10-26 07:10:40
Location: Tucson, AZ
Contact:

Post by scottwhitlock » 2007-08-01 08:01:09

Thanks so much, Martin. This is a perfect template, and I've now rewritten the macro to change all of my troublesome styles to more Word-friendly styles. Now, I have almost perfect compatibility for what I do...:)

Now, for a question. In the macro, you have the following line:

$count = Find '.+', 'aEu'

From what I understand, this declares the variable "count" and then assigns it the value of the Find results (0, 1, etc.). You applied a style to this expression in the macro. The Find expression finds any text with the style applied and then counts how many instances of that style are in the document.

Could you specifically tell me what 'aEu' means? I can't find any reference to them in the manual (but that, of course, doesn't mean they're not there).

Thanks once again, Martin. You and the others constantly remind me why Nisus is the best company around.

Scott
MacBook Pro 15
2.66 Ghz Core i7
8GB RAM
10.8.3
NWP 2.0.4
iPad 3

User avatar
martin
Official Nisus Person
Posts: 4361
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin » 2007-08-01 11:33:57

scottwhitlock wrote:Could you specifically tell me what 'aEu' means? I can't find any reference to them in the manual (but that, of course, doesn't mean they're not there).
No problem Scott. The 'aEu' is the options string for the Find (and Replace) command. Each letter has a specific effect:

a: Find (or replace) all matches, instead of just the next.
E: This specifies that PowerFind Pro should be used.
u: Indicates that we want attribute sensitive matching.

If you look on page 333 of the manual you should see a list of all available options.

Post Reply