title: How do I replace all occurrences of string in Word documents in a folder
body: <p>I've managed to find&amp; edit per one word file. With this code:</p>
  
  <pre><code>$objWord = New-Object -comobject Word.Application  
  $objWord.Visible = $false
  
  $objDoc = $objWord.Documents.Open("C:\users\stefan\test\New Microsoft Word Document.docx") 
  $objSelection = $objWord.Selection 
  
  $FindText = "that" 
  $MatchCase = $False 
  $MatchWholeWord = $true
  $MatchWildcards = $False 
  $MatchSoundsLike = $False 
  $MatchAllWordForms = $False 
  $Forward = $True 
  $Wrap = $wdFindContinue 
  $Format = $False 
  $wdReplaceNone = 0 
  $ReplaceWith = "this" 
  $wdFindContinue = 1 
  
  $a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, ` 
  $MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,` 
  $Wrap,$Format,$ReplaceWith) 
  $objDoc.Save()
  $objWord.Quit()
  </code></pre>
  
  <p>But I want to do it for whole folder. I've tried to insert something like this:</p>
  
  <pre><code>$objWord = New-Object -comobject Word.Application  
  $objWord.Visible = $false
  
   $list = Get-ChildItem "c:\users\stefan\test\*.*" -Include *.doc*
   foreach($item in $list){
   $objDoc = $objWord.Documents.Open($list.FullName,$true)
  
   $objSelection = $objWord.Selection 
  
  $FindText = "Sara" 
  $MatchCase = $False 
  $MatchWholeWord = $true
  $MatchWildcards = $False 
  $MatchSoundsLike = $False 
  $MatchAllWordForms = $False 
  $Forward = $True 
  $Wrap = $wdFindContinue 
  $Format = $False 
  $wdReplaceNone = 0 
  $ReplaceWith = "AJMOO" 
  $wdFindContinue = 1 
  
  $a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, ` 
  $MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,` 
  $Wrap,$Format,$ReplaceWith) 
  $objDoc.Save()
  $objWord.Quit()
  }
  </code></pre>
  
  <p>Also, it changes only one item that is found, but I want all items in the file.
  Thanks.</p>