title: Replace words keeping original case
body: <p>I am making a program that replaces words in an MS Word document. I want to keep the original case of the words.</p>
  <p>Let's say, there's an expression: &quot;Broken Glass&quot;. I want to modify it to &quot;Cristal Roto&quot;.</p>
  <p>I have two textboxes, Input and Output.<br />
  Input is where the term to replace goes, and output is the word with which the input term will be replaced.</p>
  <p>For this example, I would put &quot;Broken Glass&quot; in the (Input) textbox, and &quot;Cristal Roto&quot; in the (Output) textbox.</p>
  <p>The result in the Word document will be &quot;Cristal roto&quot;. The second word's first letter gets lowercased.</p>
  <pre class="lang-vb prettyprint-override"><code>Dim rng As Word.Range
  rng = objWordS.ActiveDocument.Content
      With rng.Find
          .ClearFormatting()
          .Execute(FindText:=Input.Text, _
            ReplaceWith:=Output.Text, _
            MatchWholeWord:=True, _
            Replace:=Word.WdReplace.wdReplaceAll)
      End With
  </code></pre>
  <p>I only care about the original case of the first letter of each word.</p>
  <p><strong>EDIT</strong><br />
  The reason &quot;Broken Glass&quot; ended up &quot;Cristal roto&quot; was that I missed adding this:</p>
  <pre><code>.Replacement.ClearFormatting()
  </code></pre>
  <p>Which I added just between <code>.ClearFormatting</code> and <code>.Execute</code>.</p>
  <p>Now the text in the Word File is replaced with the case I use in the Output textbox.<br />
  Still, I would like to know if there is a way to detect the case of the original word in the Word File, to automatically adapt the Output Textbox's text without using Proper Case. So:<br />
  To Replace: &quot;Broken Glass&quot; - Replace text: &quot;cristal roto&quot; - Desired result: &quot;Cristal Roto&quot;.</p>