-
Notifications
You must be signed in to change notification settings - Fork 0
/
findrep.ps1
26 lines (26 loc) · 820 Bytes
/
findrep.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$application = New-Object -comobject word.application
$application.visible=$false
$words = Get-Content C:\Users\DELL\Desktop\find.txt
$file = Read-Host 'Enter File Path'
$document = $application.documents.open($file)
$selection = $application.Selection
$matchCase=$false
$matchWholeWord=$true
$matchWildCards=$false
$matchSoundsLike=$false
$matchAllWordForms=$false
$forward=$true
$wrap=1
$format=$true
$replace=2
Foreach($word in $words)
{
$pos = $word.indexOf(":")
$findtext=$word.Substring(0,$pos)
$replacewith=$word.Substring($pos+1)
$exeRTN = $selection.find.execute($findtext,$matchCase,$matchWholeWord,$matchWildCards, $matchSoundsLike, $matchAllWordForms, $forward, $wrap, $format, $replacewith, $replace)
}
$document.save()
$document.close()
$application.quit()
$application=$null