Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Cannot find an overload for "ReplaceText" on Set-WordTextReplace cmdlet #69

Closed
Jhonrubia-LAS opened this issue Nov 19, 2021 · 2 comments

Comments

@Jhonrubia-LAS
Copy link

Jhonrubia-LAS commented Nov 19, 2021

I'm having the follwing message when using Set-WordTextReplace cmdlet

MethodException: Cannot find an overload for "ReplaceText" and the argument count: "10".

Here's a little fragment of the script I'm working on.

$doc = Get-WordDocument -Filepath $docPath
$word = "Sample"
$formatObj = New-Object Xceed.Document.NET.Formatting
$formatObj.FontColor="Red"
foreach($p in $doc.Paragraphs){
Set-WordTextReplace -Paragraph $p -SearchValue $word -ReplaceValue $word -NewFormatting $formatObj
}
@PrzemyslawKlys
Copy link
Member

It seems it doesn't like when the parameter is null. I've updated module, but not yet deployed. If you want it right away you should provide default values for the rest of parametes.

        [System.Text.RegularExpressions.RegexOptions] $RegexOptions = [System.Text.RegularExpressions.RegexOptions]::None,
        [Xceed.Document.NET.Formatting] $NewFormatting = [Xceed.Document.NET.Formatting]::new(),
        [Xceed.Document.NET.Formatting] $MatchFormatting = [Xceed.Document.NET.Formatting]::new(),
        [Xceed.Document.NET.MatchFormattingOptions] $MatchFormattingOptions = [Xceed.Document.NET.MatchFormattingOptions]::ExactMatch,

@PrzemyslawKlys
Copy link
Member

New version was released

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants