View Single Post
 
Old 04-10-2022, 03:49 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,507
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

As I said in post #5:
Quote:
Originally Posted by macropod View Post
Find/Replace can't be used to delete an empty paragraph before a table - even with a macro.
A macro you could use is:
Code:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
  With .Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "[^13]{2,}"
    .Replacement.Text = "^p"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .Execute Replace:=wdReplaceAll
    .Wrap = wdFindStop
  End With
  Do While .Find.Execute
    .End = .End - 1
    .Text = vbNullString
    .Collapse wdCollapseEnd
  Loop
End With
Application.ScreenUpdating = True
End Sub
The 'wdReplaceAll' reduces all consecutive paragraph breaks other than before a table to single paragraph breaks; the loop handles consecutive paragraph breaks before tables.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote