title: word vba loop do if find.found
body: <p>I'm trying to use Word VBA to loop through a document and what I'm trying to do is, if I find <code>.Text = "A" &amp; vbTab</code>, then I want to replace it with <code>"A: "</code>, then go to the end of the line, press the DEL key once and type <code>&lt;br&gt;</code>. But I couldn't manage it, somehow word keeps crashing when I run this code..</p>
  
  <pre><code>Sub marx()
  Dim r As Range
  Set r = ActiveDocument.Range
  
  r.Find.ClearFormatting
  With r.Find
      .Text = "A" &amp; vbTab
      .Replacement.Text = "A: "
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .MatchSoundsLike = False
      .MatchAllWordForms = False
      .Execute
  End With
  
  Do While r.Find.Found
  
  Selection.EndKey Unit:=wdLine
  Selection.Delete Unit:=wdCharacter, Count:=1
  Selection.TypeText Text:="&lt;br&gt;"
  r.Find.Execute
  Loop
  
  End Sub
  </code></pre>