Link to home
Start Free TrialLog in
Avatar of Bevos
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
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Can you clarify, please?

"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.
Avatar of Bevos
Bevos

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.
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bevos

ASKER

Perfect as always thank you Graham!