![]() ![]() I’ve added comments to explain what’s going on, but the really pertinent line is this one: Selection.MoveRight ‘Move out of the selection Selection = UCase(Selection) ‘Uppercase what was found MatchWildcards = True ‘Specify a wildcard search Replacement.Text = “” ‘Leave empty–the macro will replace the text later Text = “: ” ‘Search for colon and space followed by lowercase letter Selection.HomeKey Unit:=wdStory ‘Position cursor at top of document The only real solution is to use a macro, like this one: (How often do we get to use a fairytale allusion in technical writing?) But if your document is destined to be published in a format other than Microsoft Word, it may not be good enough, as formatting may change and, like Cinderella at the stroke of midnight, our “uppercase” letters may revert to their true lowercase selves. In some situations, that may be good enough. ![]() That should do the trick all of our lowercase letters following a colon and space are now formatted as “All caps.” The reason I said earlier that this is “ultimately unsatisfactory” is that those letters are not actually uppercase they merely look as if they’re uppercase because of their formatting. Put a check in the box labeled “All caps.” Click the Format button at the bottom left of the Replace dialog.ĩ. Make sure your cursor is in the Replace With box.ħ. ![]() In other words, if Word finds “: a” it should replace it with “: a” (the same thing it was searching for). That’s the magic code that tells Word to replace what was found with what was found. Put a check in the box labeled “Use Wildcards.” If the More button is available, click it.ģ. Press CTRL + H to bring up Word’s Replace dialog.Ģ. We can replace the lowercase letter with itself formatted as uppercase. There is, however, a rather sneaky (but ultimately unsatisfactory) workaround. In fact, if we try that, Word will simply replace what was found with the string itself, giving us this: Using a wildcard search, we can find any lowercase letter (preceded by a colon and space) by using the following string in the Find What box:īut in the Replace With box, we should use-what? We can’t use the following string because it doesn’t specify what the replacement letter should be: Unfortunately, there’s no good way to do that. I know I can do this by macro, and I have one that will do it, but I would like to do it by wildcard so I can make it part of a script I run. That is, the first letter after the colon and space is changed from lowercase to uppercase. I need a wildcard find and replace, assuming it can be done by wildcards, that searches for the following Rich Adin, the proprietor of this blog, recently sent me an interesting question. Finding and Replacing Upper- and Lowercase ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |