title: VBA Search for String and Replace
body: <p>Let's say we have a text file called text.txt. Within this text file are two lines of interest.</p>
  
  <pre><code>src="somethingrandom1111.png"
  src="morerandomnumberstuffthisnamewillvary.png"
  </code></pre>
  
  <p>What I want to do is search the entire document for src=" and then replace everything that comes after that with some other string until another " is found. So,</p>
  
  <pre><code>src="somethingrandom1111.png"
  src="morerandomnumberstuffthisnamewillvary.png"
  </code></pre>
  
  <p>Would become </p>
  
  <pre><code>src="thiswasreplace.gif"
  src="thistoo!.jpg"
  </code></pre>
  
  <p>This is a part of my code:</p>
  
  <pre><code>TempFile = Environ$("temp") &amp; "\" &amp; "index.htm"
  With TempWB.PublishObjects.Add( _
       SourceType:=xlSourceRange, _
       Filename:=TempFile, _
       Sheet:=TempWB.Sheets(1).Name, _
       Source:=TempWB.Sheets(1).UsedRange.Address, _
       HtmlType:=xlHtmlStatic)
      .Publish (True)
  End With
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, 0)
  ts = Replace(ts, 'src="', something)
  ts.Close
  </code></pre>