Well, I gave it my best shot, but I'm not able to find the correct syntax for the .execute statement. If I just do a simple .Execute() it seems to be finding the text successfully, but can't get the replace parameter right. Hopefully someone else with more COM experience will come along soon and help you out.

 Code:
Break ON
$strSrcFile = "C:\test\test-UDF-8.txt"
$strDstFile = "C:\test\test-ANSI.txt"
$strFind = "~"
$strReplace = ","
$objWord = CreateObject("Word.Application")
$RC = $objWord.Documents.Open($strSrcFile)

$objWord.Selection.Find.Text = $strFind
$objWord.Selection.Find.Replacement.Text = $strReplace
$objWord.Selection.Find.Forward = 1
$objWord.Selection.Find.Format = 0
$objWord.Selection.Find.MatchCase = 0
$objWord.Selection.Find.MatchWholeWord = 0
$objWord.Selection.Find.MatchWildcards = 0
$objWord.Selection.Find.MatchSoundsLike = 0
$objWord.Selection.Find.MatchAllWordForms = 0
$RC = $objWord.Selection.Find.Execute(Replace:=wdReplaceAll)

$RC = $objWord.ActiveDocument.SaveAs($strDstFile,2)
$RC = $objWord.Application.Quit


Edited by CitrixMan (2010-12-22 11:57 PM)