I use this code to replace text in word file its work fine in Microsoft Office but have not work on Libre office writer'
Private Sub CommandButton1_Click()
Dim AppWord As Word.Application
Set AppWord = GetObject(, "Word.Application")
AppWord.Activate
Options.DefaultHighlightColorIndex = wdNoHighlight
With ActiveDocument.Range.Find
.Text = rep.TextBox1.Value
.Replacement.Text = rep.TextBox2.Value
.Replacement.ClearFormatting
.Replacement.Font.Italic = False
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Execute Replace:=wdReplaceAll
End With
rep.Hide
End Sub