Hi, I am trying to make a macro which takes an input of some words in an input dialog box, finds all those words in the document and bolds them. I recently switched to Linux and this is crucial for some of the work that I do. I had a macro for Microsoft Word that did the same, but can’t seem to figure out how to do it in LibreOffice Writer.
My macro for Microsoft Word that I used on Windows;
Attribute VB_Name = "Bold_All_Keywords"
Sub BoldAllKeywords()
Dim xFind As String
Dim xReplace As String
Dim xFindArr, xReplaceArr
Dim I As Long
Application.ScreenUpdating = False
xFind = InputBox("Enter items to be found here,seperated by comma: ", "Bold all Keywords")
xReplace = InputBox("Enter new items here, seperated by comma: ", "Bold all Keywords")
xFindArr = Split(xFind, ",")
xReplaceArr = Split(xReplace, ",")
If UBound(xFindArr) <> UBound(xReplaceArr) Then
MsgBox "Find and replace characters must be equal.", vbInformation
Exit Sub
End If
For I = 0 To UBound(xFindArr)
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Replacement.Font.Bold = True
.Text = xFindArr(I)
.Replacement.Text = xReplaceArr(I)
.Format = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Next
Application.ScreenUpdating = True
End Sub
Any help with a similar macro for LibreOffice would be great! TIA!