Bevos
asked on
Word macro to find and replace % to percent conditionally
Hello, I would like to get some assistance in writing a find and replace Word 2007 macro from the folks here. I would like the macro to perform two conditional operations.
First, for any text that is not enclosed by ( ) or [ ] find the % sign and change it to the word 'percent' without the single quotes.
Next, find any instances of percent enclosed by ( ) or [ ] and change this to the % symbol.
Any help would be greatly appreciated as always.
Thanks,
Bev
First, for any text that is not enclosed by ( ) or [ ] find the % sign and change it to the word 'percent' without the single quotes.
Next, find any instances of percent enclosed by ( ) or [ ] and change this to the % symbol.
Any help would be greatly appreciated as always.
Thanks,
Bev
ASKER
Hi Graham, thanks so much for the response here is an example:
When I said any text I mean that the whole word document would be scanned for these changes. Sorry if there was confusion by the vague wording.
Before correction:
This is an example paragraph in which % is used incorrectly. However if someone uses parentheses then (percent) should use a symbol instead. This should be the case even if large amounts of text are in parentheses. [This example of percent should be informative %]. So basically percent is spelled out whenever not enclosed by parentheses or brackets.
After correction:
This is an example paragraph in which percent is used incorrectly. However if someone uses parentheses then (%) should use a symbol instead. This should be the case even if large amounts of text are in parentheses. [This example of % should be informative %]. So basically percent is spelled out whenever not enclosed by parentheses or brackets.
When I said any text I mean that the whole word document would be scanned for these changes. Sorry if there was confusion by the vague wording.
Before correction:
This is an example paragraph in which % is used incorrectly. However if someone uses parentheses then (percent) should use a symbol instead. This should be the case even if large amounts of text are in parentheses. [This example of percent should be informative %]. So basically percent is spelled out whenever not enclosed by parentheses or brackets.
After correction:
This is an example paragraph in which percent is used incorrectly. However if someone uses parentheses then (%) should use a symbol instead. This should be the case even if large amounts of text are in parentheses. [This example of % should be informative %]. So basically percent is spelled out whenever not enclosed by parentheses or brackets.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect as always thank you Graham!
"for any text that is not enclosed by ( ) or [ ] ". 'Any text' is a bit vague. It could be a whole document, a paragraph, a word, one character or anything in between.
For that which is already enclosed, what needs to be changed to a % symbol?
Perhaps a few examples would help.