Page 1 of 1

Save for Word Macro

Posted: 2007-07-30 21:19:25
by scottwhitlock
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

Posted: 2007-07-31 17:48:52
by martin
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'

Posted: 2007-08-01 08:01:09
by scottwhitlock
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

Posted: 2007-08-01 11:33:57
by martin
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.