Darren Hill
Darren Hill

Reputation: 1

Capitalize a section of text or letter based upon a predefined word WORD (d) = WORD (D)

In a Word document, I am trying to make a section of text capitalized based upon a specific text/case. I have very specific acronyms followed by a number and letter Example "txt 14 a" that I am wanting to format section of the text to uppercase. I can get it go from "txt 14 a" to "TXT 14(a)". But I want the "(a)" to end up "(A)". So starting from "txt 14 a", my goal would for it to end up "TXT 14(A)". I have tried using:

With Selection.Find
        .Text = "TXT ([0-9]) ([a-z])"
        .Replacement.Text = "TXT \1(\2)"
        .Forward = False
        .Wrap = wdFindContinue
        .FORMAT = False
        .MatchCase = False
        .MatchWholeWord = True
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Range.Case = wdUpperCase
    Selection.Find.Execute Replace:=wdReplaceAll

But that is obviously not working. I am a newbie when it comes to Word VBA macros. Can someone point me in the right direction?

TXT 5(b) = TXT 5(B). Actual results were capitalizing everything on the page instead of section.

Upvotes: 0

Views: 24

Answers (0)

Related Questions