Hi there. I want replace some string within Word Document using ActiveX and JavaScript, now I have something like this:
var text = Selection.Text;
Selection.Text = text.replace('somesting','somevalue');
But after that I loose all formaing. If I record macros in WinWord I get this:
With Selection.Find
.Text = "somestring"
.Replacement.Text = "somevalue"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.Execute Replace:=wdReplaceAll
So, how can I rewrite the last string with JS?