View Single Post
 
Old 05-01-2021, 07:49 PM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Hi Andrew,

I added an array to attack more than one word, but also need to reset the left indent. Can't seem to find the right syntax.

This works for the array, but not the left indent.

Code:
Sub ReplaceWords()
    Dim MyList As Variant: MyList = Array("MESSAGE:", "SCRIPTURE:")
    Dim oRng As Word.Range: Set oRng = ActiveDocument.Range
    Dim i As Integer
    For i = 0 To UBound(MyList)
        With oRng.Find
            .ClearFormatting
            .Text = MyList(i) & vbTab
            .Replacement.Text = MyList(i) & "  "
            .Execute Replace:=wdReplaceAll
'            .ParagraphFormat.LeftIndent = InchesToPoints(0)
        End With
    Next i
End Sub
Reply With Quote