Created
July 6, 2024 23:42
-
-
Save eugrus/0a00ea39d46714a02b5c271034d9daee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[string]$findText, | |
[string]$replacewithText | |
) | |
$msword = [System.Runtime.Interopservices.Marshal]::GetActiveObject("Word.Application") | |
# https://learn.microsoft.com/ru-ru/office/vba/api/word.find.execute | |
$MatchCase = $false | |
$MatchWholeWord = $true | |
$MatchWildcards = $false | |
$MatchSoundsLike = $false | |
$MatchAllWordForms = $false | |
$Forward = $false # перепроверить | |
$Wrap = 1 # https://learn.microsoft.com/ru-ru/office/vba/api/word.wdfindwrap | |
$Format = $false | |
$Replace = 2 # = wdReplaceAll https://learn.microsoft.com/ru-ru/office/vba/api/word.wdreplace | |
$doc = $msword.ActiveDocument | |
$doc.Content.Find.Execute($findText, $MatchCase, $MatchWholeWord, $MatchWildcards, $MatchSoundsLike, $MatchAllWordForms, $Forward, $Wrap, $Format, $replacewithText, $Replace) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment