View Single Post
 
Old 11-13-2023, 06:23 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

It seems that Vivka's code misses the last instance of your keyword. I also don't understand the reason for the If .found condition. You might try:


Code:
Sub Move_Two_Lines_Down()
Dim oRng As Range
  Set oRng = ActiveDocument.Range
  Application.ScreenUpdating = False
  With oRng.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Keywords ^#"
    .Forward = True
    .Format = True
    .Wrap = wdFindStop
    While .Execute
      oRng.Paragraphs(1).Range.Cut
      oRng.Move unit:=wdParagraph, Count:=2
      oRng.Paste
      If oRng.End = ActiveDocument.Range.End - 1 Then
        oRng.InsertBefore vbCr
        oRng.Paragraphs.Last.Next.Range.Delete
      End If
       oRng.Collapse wdCollapseEnd
    Wend
  End With
  Application.ScreenUpdating = True
lblExit:
  Set oRng = Nothing
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote