toolsmith has asked for the wisdom of the Perl Monks concerning the following question:
$comments = @' Script name: Replace-WordText.ps1 Created on: Tuesday, April 03, 2007 Author: Kent Finkle Purpose: How can I use Windows Powershell to Find and Replace Text in +a Microsoft Word Document? '@ $objWord = New-Object -comobject Word.Application $objWord.Visible = $True $objDoc = $objWord.Documents.Open("C:\Scripts\Test.doc") $objSelection = $objWord.Selection $FindText = "Contoso" $MatchCase = $False $MatchWholeWord = $False $MatchWildcards = $False $MatchSoundsLike = $False $MatchAllWordForms = $False $Forward = $True $Wrap = $wdFindContinue $Format = $False $wdReplaceNone = 0 $ReplaceWith = "" $wdFindContinue = 1 $a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, +` $MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,` $Wrap,$Format,$ReplaceWith,$wdReplaceNone) If ($objSelection.Find.Found) { Write-Host("The search text was found.") } Else { Write-Host("The search text was not found.") }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: MS Word OLE help
by Anonymous Monk on Sep 12, 2010 at 18:27 UTC | |
|
Re: MS Word OLE help
by ww (Archbishop) on Sep 12, 2010 at 17:14 UTC | |
by BrimBorium (Friar) on Sep 12, 2010 at 18:04 UTC | |
by toolsmith (Novice) on Sep 12, 2010 at 19:47 UTC | |
by Corion (Patriarch) on Sep 12, 2010 at 19:48 UTC | |
|
Re: MS Word OLE help
by planetscape (Chancellor) on Sep 12, 2010 at 23:26 UTC |