简体   繁体   中英

Change font color for certain text in MS Word

I have very little VBA experience and a have a large document that contains the text similar to below:

"(+12.3%) which translates to (-$78.9M)"

Kind of similar to this question I want to change text that follows the symbol "+" or "-" to green and red respectively, while keeping text black.

Is it possible for a VBA code that can automatically do this?

You can do that with two wildcard Find/Replace operations, without recourse to a macro, using:

Find = +[0-9.%$M]{1,}
Replace = ^&

with the replacement font colour set to green, and

Find = \-[0-9.%$M]{1,}
Replace = ^&

with the replacement font colour set to red. You could, of course, use the macro recorder to create a single macro containing both operations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM