The following collapse the selected paragraph if it is formatted with a built-in heading style:
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
If InStr(Selection.Style, "Heading") = 1 Then
Selection.Paragraphs(1).CollapsedState = True
End If
End Sub