Hello all,

I have several thousand Word files that have inconsistent formatting. I have a macro that runs on a single word file at a time. I would like to use VB code to use a for loop to run on all the Word files in the directory. The below is my macro.

Code:
Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[^13]{2,}"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindStop
    .Format = False
    .MatchWildcards = True
    .Execute
  End With
  Do While .Find.Found
    For i = 1 To .Paragraphs.Count
      With .Paragraphs(i)
        If .Borders(wdBorderBottom).LineStyle <> wdLineStyleNone Then
          .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
          .Range.InsertBefore "______________________" & _
            "________________________________________" & _
            "_________________________________________"
        End If
      End With
    Next
    .Collapse wdCollapseEnd
    .Find.Execute
  Loop
End With
Application.ScreenUpdating = True
End Sub