View Single Post
 
Old 06-15-2021, 03:04 PM
macropod's Avatar
macropod macropod is offline Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Each heading can have only one paragraph Style. If you want to delete all headings, simply use Find/Replace to delete all content in each heading Style. That would be way quicker than looping through all paragraphs and testing them. For example:
Code:
Sub DeleteHeadings()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Content.Find
  .ClearFormatting
  .Format = True
  .Text = ""
  .Replacement.Text = ""
  .Wrap = wdFindContinue
  For i = 1 To 9
    .Style = "Heading " & i
    .Execute Replace:=wdReplaceAll
  Next i
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote