Pretend I have no idea what I'm doing and that I know nothing about perl.
I have done "Record Marcos" in MS Word and done some editing of those macros.
If I had a series of find/replace commands, what would the structure of that be? I can figure out the regular expressions, but what would the blank object be... sort of like the shell of an html document.
My purpose is to move away from word. I get 100-200 ms word docs a month from various sources with different structures and presentational formatting. I need to get them down to lean, economical, AP style documents with limited presentational markup for import into InDesign.
I've used Word for years, but the scripting is beyond me... I'm looking for something simple and elegant. I think NWP will work, I just need the structure to get started.
Find/Replace multiple items
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
The general structure to run multiple find & replace operations in a macro would be this:
If you want to use normal Find & Replace (eg: not regular expressions / PowerFind) then the options string is simply 'a' to specify replace all, eg:
If you want to use PowerFind then you'll want to add an 'e', or a capital 'E' for PowerFind Pro, eg:
Code: Select all
Find and Replace 'FindWhat', 'ReplaceWith', 'options'
Find and Replace 'FindWhat2', 'ReplaceWith2', 'options'
Code: Select all
Find and Replace 'Foo', 'Bar', 'a'
Find and Replace 'Red', 'Blue', 'a'
Code: Select all
Find and Replace '\$(\d+)(?!\.)', '$\1\.00', 'Ea'
Find and Replace '(?<=\s)(\d+)(?!\.)', '[\1]', 'Ea'
So I just use simple statements according to the models you provided? No Document Declarations (as if I even know what that is) or the anything like Microsoft.Sucks.End.With?
That's almost too easy.
You're saying I could make a simple spreadsheet of the few dozen things I want to correct, write a formula to format those items into text that I save as a macro and Bob's my uncle?
Sweet.
That's almost too easy.
You're saying I could make a simple spreadsheet of the few dozen things I want to correct, write a formula to format those items into text that I save as a macro and Bob's my uncle?
Sweet.
Re: Find/Replace multiple items
It was easier even: In Nisus Writer Classic you just macroized your Find/Replace String with a "macroize" button in the lower left corner of the F/R Window.
By the way: will Nisus Writer Pro have such a feature some day?
By the way: will Nisus Writer Pro have such a feature some day?
- martin
- Official Nisus Person
- Posts: 5227
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Re:
That's exactly right. There's really only one thing that I can think of that would make things more complicated for you: searching for an apostrophe or backslash. You have to "escape" the characters. So, if you wanted to replace the word "it's" you'd precede the apostrophe with a single backslash, eg:mwiseman wrote:So I just use simple statements according to the models you provided?
Code: Select all
Find and Replace 'it\'s', 'it is', 'a'
Code: Select all
Find and Replace '1\\2', 'one half', 'a'
It should indeed- we're looking to add that feature in sometime soon.Matze wrote:It was easier even: In Nisus Writer Classic you just macroized your Find/Replace String with a "macroize" button in the lower left corner of the F/R Window.
By the way: will Nisus Writer Pro have such a feature some day?